By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,645 Members | 1,047 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,645 IT Pros & Developers. It's quick & easy.

About Shared properties in ASP.NET

P: n/a
Hi,
I'm using a custom class in my ASP.NET which has a Shared property.
I don't want this Shared property to be shared between users because of
thread concurrent accesses problems.
I just want it to be shared between the several instances of the class
belonging to the same request/user.
I think I've read somewhere that shared properties are not shared among
users in ASP.NET. (that would be logic as a shared property should die after
each user's request has ended)
So I think I don't have to use SyncLock inside this Shared property as each
client request is run completely separately and a thread from a request
won't access the same shared property as another request's thread.
Am I right?
Thanks for your answer.

Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
> I think I've read somewhere that shared properties are not shared among
users in ASP.NET. (that would be logic as a shared property should die
after
each user's request has ended)
Afraid not. Shared (static) objects are stored in the heap, and are
singletons (there is only one, no instance). The use of the syntax "shared"
is, IMHO, unfortunate, in that it is a little misleading. But what is
important is what it means. Instantiated objects are (copies of execution
code) placed on the stack, a volatile region of memory where instances are
placed while being used, and removed afterwards. Shared (static) objects
remain in the heap, a region of code into which the program execution code
is loaded (from the DLL) at startup.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Henri" <hm********@hotmail.com> wrote in message
news:ed*************@TK2MSFTNGP12.phx.gbl... Hi,
I'm using a custom class in my ASP.NET which has a Shared property.
I don't want this Shared property to be shared between users because of
thread concurrent accesses problems.
I just want it to be shared between the several instances of the class
belonging to the same request/user.
I think I've read somewhere that shared properties are not shared among
users in ASP.NET. (that would be logic as a shared property should die
after
each user's request has ended)
So I think I don't have to use SyncLock inside this Shared property as
each
client request is run completely separately and a thread from a request
won't access the same shared property as another request's thread.
Am I right?
Thanks for your answer.

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.