Are Application collection and Page.Cache thread safe?

M

Max2006

Hi,

Since Application collection and Page.Cache can be shared among all
sessions, I wonder if they are thread safe?

Thank you,
Max
 
B

bruce barker

the collections are thread safe, but the objects you add to the
collection may or may not be.

-- bruce (sqlwork.com)
 
S

Steve C. Orr [MCSD, MVP, CSM, ASP Insider]

Cache is thread safe.
Application is also thread safe as long as you remember to use its Lock and
Unlock methods.
 
S

Steven Cheng[MSFT]

Hi Max,

Application State is provided in ASP.NET for compatible with classic ASP
application and you need to perform lock/unlock over it to make sure
thread-safe. Application Cache in ASP.NET is built-in thread safe, that
means you can freely store and access objects in Cache entry without
additional lock/unlock(or other synchronize operations). However, I agree
with Bruce that you need to take care of the objects you want to store in
Cache, whether the objects (you'll store in Cache, or to share them) is
thread-safe is important if you'll take care of the concurrent accessing in
your web application.

BTW, I also saw your another thread "Can we use static table adapters in
highly concurrent web sites?" in the newsgroup, and some other members have
also replied you there. Please feel free to have a look also.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Steven Cheng[MSFT]

Hi Max,

Does the info in previous messages help you? If you have any other
questions ,please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 

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,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top