Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Share class variables between different processes

Status
Not open for further replies.

UdoScheuvens

Programmer
Apr 12, 2001
42
DE
Hello,

I want to create a variable within a class which is shared by all instances created by any process in the system. The declaration

Code:
Private Shared mySharedVar As Integer

creates a variable that is only shared between instances of one and the same process. Is there a way???

Udo
 
public shared perhaps


Christiaan Baes
Belgium
"What a wonderfull world" - Louis armstrong
 
Take a look at the AppDomain class.

All .NET code runs inside one, so any sharing (if possible) would be done at that level.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
public shared" doesn't help.

The AppDomain class sounds interesting, but I'm absolutely not familiar with it. Could anybody give some more precise instruction how to make App1 share a class variable with App2? (i can make sure that App2 is started by App1)

Udo
 
It is not possible with "Shared" because that governs a single AppDomain. A Process could have multiple AppDomains. Each process can have a single instance of the Framework BUT each process can be running a different version of the Framework from other processes. The best bet is .Net remoting, but "locking" the data across processes and AppDomains could be a performance problem.

Type "remoting" in the Help Index.

"NET remoting enables client applications to use objects in other processes on the same computer or on any other computer available on its network. You can also use .NET remoting to communicate with other application domains in the same process. .NET remoting provides an abstract approach to interprocess communication that separates the remotable object from a specific server and client process and from a specific mechanism of communication. As a result, it is flexible and easily customizable. You can replace one communication protocol with another, or one serialization format with another without recompiling the client or the server."

Forms/Controls Resizing/Tabbing
Compare Code
Generate Sort Class in VB
Check To MS)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top