Hi Beren,
First, yes, your Cache isn't nearly as safe a container as you might think.
In fact, it will be dumped every time the Application shuts down, which will
happen any time there are no requests from anyone for 20 minutes. You can
extend the lifetime of the Application just like extending the lifetime of
the Session, but that only reduces the issue, and does not elimate it.
So, the first thing you need to do is determine how critical these tasks
are. What happens if they don't run? If they are indeed critical, you need a
different solution than Cache. Any solution that is reliable would involve
serializing data to the disk, whether this is via XML, binary files,
database, or possibly Windows Messaging services.
That also means that you're going to have to remodel your tasks not to use
delegates. If you use Windows Messaging services, or the soon-to-be-released
Indigo Services, you get both reliability of data, plus guaranteed delivery
of the message. It is important to note that delegates are not the only way
to determine what method is executed. Any message can include some sort of
information about what should be done in response to the message.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Big things are made up of
lots of little things.
"Beren" <be***@angband.me> wrote in message
news:i2********************************@4ax.com...
Hello
I'm trying to use Cache expiration and its callback feature to easily
add automated tasks programmatically. The task should be run when the
Cache object expired
The problem I'm facing is that some tasks will only be expiring (thus
running) in 2 months.
What if the server needs to reboot? Will the Cache be lost (and with
it all my Tasks) ?
If so, how could I save the Cache Objects of choice (my Tasks) exactly
as they are. These Tasks contain a Delegate holding the address of the
method to run, so I doubt I can serialize this to XML or to a DB...
All suggestions and advice are very welcome!
Beren.