Are Application collection and Page.Cache thread safe?

  • Thread starter Thread starter Max2006
  • Start date Start date
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
 
the collections are thread safe, but the objects you add to the
collection may or may not be.

-- bruce (sqlwork.com)
 
Cache is thread safe.
Application is also thread safe as long as you remember to use its Lock and
Unlock methods.
 
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.
 
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.
 
Back
Top