473,396 Members | 2,068 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.

How many instances of a shared variable are there

If I define a variable in a module there is only one instance of the
variable for all instances of the class.

If I define a variable within a class there is an instance of the variable
for each instance of the class.

What happens if the variable in the class is defined as shared? How many
instances of the variable are there.

Thanks
Nov 20 '05 #1
7 1127
* " SamSpade" <st**************@REMOVEaol.com> scripsit:
If I define a variable in a module there is only one instance of the
variable for all instances of the class.

If I define a variable within a class there is an instance of the variable
for each instance of the class.

What happens if the variable in the class is defined as shared? How many
instances of the variable are there.


One per process that uses the class library.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2
Hi,

One.

Ken
----------------
" SamSpade" <st**************@REMOVEaol.com> wrote in message
news:uC*************@TK2MSFTNGP10.phx.gbl...
If I define a variable in a module there is only one instance of the
variable for all instances of the class.

If I define a variable within a class there is an instance of the variable
for each instance of the class.

What happens if the variable in the class is defined as shared? How many
instances of the variable are there.

Thanks

Nov 20 '05 #3
Thanks to both

" SamSpade" <st**************@REMOVEaol.com> wrote in message
news:uC*************@TK2MSFTNGP10.phx.gbl...
If I define a variable in a module there is only one instance of the
variable for all instances of the class.

If I define a variable within a class there is an instance of the variable
for each instance of the class.

What happens if the variable in the class is defined as shared? How many
instances of the variable are there.

Thanks

Nov 20 '05 #4
SamSpade,
As the other's have stated, there is one per process.

However! if you apply the System.ThreadStaticAttribute to the Shared
variable (or Module variable) you will have one per thread in your process.

Hope this helps
Jay

" SamSpade" <st**************@REMOVEaol.com> wrote in message
news:uC*************@TK2MSFTNGP10.phx.gbl...
If I define a variable in a module there is only one instance of the
variable for all instances of the class.

If I define a variable within a class there is an instance of the variable
for each instance of the class.

What happens if the variable in the class is defined as shared? How many
instances of the variable are there.

Thanks

Nov 20 '05 #5
One per process that uses the class library.


I believe it's actually one per appdomain.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 20 '05 #6
* Mattias Sjögren <ma********************@mvps.org> scripsit:
One per process that uses the class library.


I believe it's actually one per appdomain.


OK ;-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #7
Thanks for the info
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:OF**************@TK2MSFTNGP11.phx.gbl...
SamSpade,
As the other's have stated, there is one per process.

However! if you apply the System.ThreadStaticAttribute to the Shared
variable (or Module variable) you will have one per thread in your process.
Hope this helps
Jay

" SamSpade" <st**************@REMOVEaol.com> wrote in message
news:uC*************@TK2MSFTNGP10.phx.gbl...
If I define a variable in a module there is only one instance of the
variable for all instances of the class.

If I define a variable within a class there is an instance of the variable for each instance of the class.

What happens if the variable in the class is defined as shared? How many
instances of the variable are there.

Thanks


Nov 20 '05 #8

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

Similar topics

1
by: Mike Frayn | last post by:
Hello there. I'm kinda new to Java, did some last year and have forgotten it all, but am experienced enough with C++. I have a problem here that I would imagine is solved very easily. I have...
2
by: John Wohlbier | last post by:
Hi, I have a basic programming question regarding classes in python. I want to have a list of "primaryClass" instances, and in each instance of primaryClass I would like a list of "subClass"...
11
by: Mike | last post by:
Looking to find any information on how to properly configure multiple instances of DB2. This is on Win2k db2 ver 7.2. I am basically looking for information on how the multiple instance settings...
2
by: Markus Prediger | last post by:
Hi NG, I have an asp.net project that uses an vb6 com object for some database-manipulation (I cannot rewrite it in .net, sorry, its not my decision). I want it to be instanciated seperately...
2
by: Saber | last post by:
Public Class User Private _id, _P, _L, _R As Integer Private _balance As Int64 Private _name, _family, _tel1, _tel2, _mobile, _city, _accountNumber As String Private _password, _email,...
0
by: Larry Lard | last post by:
This came out of a thread explaining to "BK" about error BC42025 ("Access of shared member through an instance; qualifying expression will not be evaluated"); Frans Clasener then came up with...
9
by: Amit Bhatia | last post by:
User-Agent: OSXnews 2.081 Xref: number1.nntp.dca.giganews.com comp.lang.c++:817840 hi, I was wondering how to do the following. I have a class A, class A{ //; int a;
4
by: Mike | last post by:
Class A public objX I want to create 2 or more instances of Class A and have the same value for objX in all instances. Instance1 of Class A Instance2 of Class A Instance3 of Class A
1
by: aknoch | last post by:
My basic situation is this - I ONLY want duplicates, so the opposite of DISTINCT: I have two tables. Ordinarily, Table1ColumnA corresponds in a one to one ratio with Table2ColumnB through a...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.