Access Cache from Another Thread?

G

Guest

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
 
S

Scott Allen

The cache isn't tied to a specific request or response so I don't see any
problem accessing the cache from a background thread.

The only reservation I'd have is over this statement:
some items need to be accessed and/or inserted
into the Cache for possible subsequent processing by another page.

The cache can expire items and kick them out of the cache if there is some
memory pressure. What happens if the next page doesn't find the results computed
by the background thread in the page?
 

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

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top