Global shared values

D

Darin

I have an application that is one EXE with mutliple DLL's. In one of the
DLL's (libs.dll) that the EXE has refeneced, I have:

Public Class Globals
Public Shared gLogin as String
End Class

This variable is ued throughout my program in libs.dll, and other DLLs.

The user then starts up another occurance of the application. They login
and the gLogin variable is set.

Are the two programs using the same or different memory areas for this
global data? If either exit the software, should that do anything to the
other gLogin for the other program?

What are other people's thoughts on global variables. I know they aren't
great things to use, but I haven't figured out a clean method of passing
data around to different forms that may or may not get used.

Thanks.
Darin
 
A

Armin Zingler

Darin said:
I have an application that is one EXE with mutliple DLL's. In one of
the DLL's (libs.dll) that the EXE has refeneced, I have:

Public Class Globals
Public Shared gLogin as String
End Class

This variable is ued throughout my program in libs.dll, and other
DLLs.

The user then starts up another occurance of the application. They
login and the gLogin variable is set.

Are the two programs using the same or different memory areas for
this global data? If either exit the software, should that do
anything to the other gLogin for the other program?

No, processes don't share data. Look for "remoting" to interact between
processes.
What are other people's thoughts on global variables. I know they
aren't great things to use, but I haven't figured out a clean method
of passing data around to different forms that may or may not get
used.

There are no global variables. Variables are either shared or instance, and
they are accessible or not. I'd make a variable only shared if it can be
changed to any value without breaking consistence. To pass data between
objects, I'd pass the reference to the object around.

--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top