scheduling thru posting on a public webhost??

  • Thread starter Thread starter Ivan Demkovitch
  • Start date Start date
I

Ivan Demkovitch

Hi!

If I understand caching properly:

1. Create object in cache and set expiration Time to let's say 1 minute
2. Specify delegate which will be called on object expiration. Here we will
restore object and do some other stuff.

Basically we have timer-like application which lives by itself without
user's hitting website.

Does anybody use this technique to schedule events or some specific
processing?
 
A more explicit way to handle scheduled / timed events from inside an
ASP.NET application is to create a System.Timers.Timer object during
the Application_Start event in global.asax.

i.e.

protected void Application_Start(Object sender, EventArgs e)
{
System.Timers.Timer myTimer = new System.Timers.Timer();
myTimer.Enabled = true;
myTimer.Interval = (60000 * 15);
myTimer.Elapsed +=
new System.Timers.ElapsedEventHandler(myTimer_Elapsed);

}

protected void myTimer_Elapsed(
object sender,
System.Timers.ElapsedEventArgs e
)
{
// do some work
}


I wouldn't use the cache expiration to do anything other than refresh
the cache. Any other behavior might not be obvious to someone coming
in to do maintenance on the softwrae.

HTH,
 
Whatever you do, note that your schedule will stop when the server is
rebooted, or IIS is restarted.
Then you'll have to wait until the first visitor visits your page ...
Hopefully you have a real busy page ...

Wim
 
Back
Top