HighTechTalks DotNet Forums  

Access Cache object from Background Thread Possible?

ASP.net Caching microsoft.public.dotnet.framework.aspnet.caching


Discuss Access Cache object from Background Thread Possible? in the ASP.net Caching forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Christopher
 
Posts: n/a

Default Access Cache object from Background Thread Possible? - 01-19-2005 , 09:19 PM






In one of our ASP.NET Pages, we are starting a new background thread that we
do not need to go and get any status on or use after the page finishes. The
thread merely does some background stuff on its own and finishes on its own,
no feedback back to the user (by design). Within that thread however, some
items need to be accessed and/or inserted into the Cache for possible
subsequent processing by another page. Many examples I see of background
threads include access to the Session object however in our tests here we
found we could not access the Response or Request objects in a background
thread, which is by design.

We passed in the Cache object as a property to our background thread and can
access it just fine, but we wanted to know if this was an okay way to access
the Cache from a background thread or are there better ways of accessing
Cache from a background thread?

Thanks so much I appreciate it!

Christopher


Reply With Quote
  #2  
Old   
Alvin Bruney [MVP]
 
Posts: n/a

Default Re: Access Cache object from Background Thread Possible? - 01-19-2005 , 10:24 PM






No, this is fine. One point to note, the cache object is thread safe by
design but you are now manipulating the cache from two sequential streams
(thread, and main app thread) so you should be aware of potential race
conditions. Ex. Main app saves object A to cache and then retrieves object
A, but actually gets object B because the background thread overwrote A with
B...

--
Regards,
Alvin Bruney

Shameless Author plug
The Microsoft Office Web Components Black Book with .NET
http://tinyurl.com/27cok


"Christopher" <Christopher (AT) discussions (DOT) microsoft.com> wrote

Quote:
In one of our ASP.NET Pages, we are starting a new background thread that
we
do not need to go and get any status on or use after the page finishes.
The
thread merely does some background stuff on its own and finishes on its
own,
no feedback back to the user (by design). Within that thread however,
some
items need to be accessed and/or inserted into the Cache for possible
subsequent processing by another page. Many examples I see of background
threads include access to the Session object however in our tests here we
found we could not access the Response or Request objects in a background
thread, which is by design.

We passed in the Cache object as a property to our background thread and
can
access it just fine, but we wanted to know if this was an okay way to
access
the Cache from a background thread or are there better ways of accessing
Cache from a background thread?

Thanks so much I appreciate it!

Christopher




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.