473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Statics and threading

Hi

I am writing a fairly simple desktop app which will not be subject to great loads. Therefore this question is more for academic purposes

I have implemented a class that declares only static members and functions. I use this class to control my connections. There are just 2 methods; Open and Close. The connection object within the class is static and has public scope. It is created when the app is started. (This obviously enables connection pooling

This makes the code very simple. When I want to use a connection I just call myConnectionClass.Conn. No need to dimension anythinig, dispose etc. I just make sure I close it when the routine has finished

Is this OK? I am worried that by declaring just 1 connection as a static there will be threading issues. i.e. There may be a que of users waiting to use the single, shared connection object

What do you experts think

Andy Newland (MCAD

Nov 22 '05 #1
2 1303
Should OF COURSE of written Shared NOT static!!!!
Nov 22 '05 #2
> Hi,

I am writing a fairly simple desktop app which will not be subject to great loads. Therefore this question is more for academic purposes!
I have implemented a class that declares only static members and functions. I use this class to control my connections. There are just 2
methods; Open and Close. The connection object within the class is static
and has public scope. It is created when the app is started. (This obviously
enables connection pooling)
This makes the code very simple. When I want to use a connection I just call myConnectionClass.Conn. No need to dimension anythinig, dispose etc. I
just make sure I close it when the routine has finished.
Is this OK? I am worried that by declaring just 1 connection as a static there will be threading issues. i.e. There may be a que of users waiting to
use the single, shared connection object.
What do you experts think?


What are you connecting to? How many people are doing it? Is there a good
reason to limit things to one connection? If you're designing an FTP server,
then things need to be more complex. If you're designing a simple point to
point application between 2 processes or machines it might work. Make sure
you understand the consequences of any design decisions you make, and
providing more detail would help people give you better advice.

Steve
Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Andy Newland UK | last post by:
Hi I am writing a fairly simple desktop app which will not be subject to great loads. Therefore this question is more for academic purposes I have implemented a class that declares only static...
6
by: Spacen Jasset | last post by:
Since it says in the standard that the order of initialization of variables is indeterminate, does this also apply to a static within a function? e.g. int GetInt() { static int test = 458;...
4
by: Martin | last post by:
I have some classes with statics public variables.... the problem is that the gcc compiles fine the files but in the linking process gcc says "multiple definitions of MyClass::Variable" or...
5
by: Stuart MacMartin | last post by:
I have a problem with static lifetime (order of destruction of statics within different cpp files). I have a workaround that happens to work in my case. I'd like to know if this is luck or...
6
by: Andrew Ducker | last post by:
Let's say I have a root class called RootBusinessService and I then want to have 25 business service classes based off of it. And each class has a property that's shared between all instances of...
20
by: Aek | last post by:
We recently moved our large codebase over from VS7 to 8 and found that we now get access violations in atexit calls at shutdown when debugging the application in VS2005. This occurs in static...
3
by: DR | last post by:
I heard there is some trick to referencing statics in C# CLR stored procedure without having to mark the assembly as unsafe. Does anyone know this? This is usefull as the case of needing a little...
3
by: DR | last post by:
I heard there is some trick to referencing statics in VB.NET CLR stored procedure without having to mark the assembly as unsafe. Does anyone know this? This is usefull as the case of needing a...
3
by: Peter | last post by:
Hi I can create types from dynamic loaaded assemblies (Assembly.Load) with Assembly.GetTyp( <typename) - OK I need a reference to the assembly (just Type.GetType() do not work ) now my...
3
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... At least by the group title, this seems like a question for dotnet.framework.aspnet.caching but that group seems pretty slow. I'm trying to sort things out with a co-worker. We've got...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.