Scope of Shared Properties

D

daokfella

Quick question:

If my page instantiates a class that has a protected shared property,
is that property shared across all instances of the class...even those
that I didn't instantiate, but another user accessing the page did?

Thanks!
 
M

Mark Fitzpatrick

From my understanding of the shared descriptor in VB (I use C# mostly so I
may be a bit off), the shared property is never truly instantiated, it's
available directly whether the class is instantiated or not. Shared/static
members and properties should be able to be called without the class ever
being created. So yes, all the users who access this property should have
exactly the same value, which could lead to some very interesting results if
they are trying to write to it at the same time. An example of a shared
property for a class may be something like total number of users in a
membership system. All accounts will see the same total. Anytime a new
account is added and the shared property is incremented, all should see the
increment, but some locking should definitely be done when modifying this
value.
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top