cache clearing upon app shutdown

M

Micha³ Januszczyk

is there any way to tell whether the application has entered the shutdown
state ?
I put some data into aspnet cache. Special callback method is specified that
should be called when cache item is removed from cache. The handler method
deletes
specified file from disk.

The problem is that the cache is cleared upon application shutdown
and all cached objects are implicitly removed. This involves that my handler
is also called and the files are deleted, however they should not.

I would like to have the following construct:


void CacheItemRemovedHandler(....)
{

....

if( ! application_is_shutting_down)
{
String currentDir;
File.Delete(currentDir + cacheKey);
}

....

}

//the question is:
how to get application_is_shutting_down value ?


I tried to set application_is_shutting_down in application_end event handler
(in Global.asax) but it happens _after_ the cache is cleared upon shutdown.
Is there any other event (occuring upon app shutdown) that happens before
aspnet cache clearing ?


Thanks for help
Michal Januszczyk
 

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,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top