Hi,
While I realise that this may not be a very nice solution architecturally, I
kick off a Scheduler in an ASP.NET 2.0 webservice in Application_Start()
which is supposed to call a stored proc in a database once a day every day.
The code works on the day that the webservice is deployed, but not on
subsequent days unless I restart IIS.
The code looks like this:
void Application_Start(object sender, EventArgs e)
{
Scheduler sch = new Scheduler();
}
public Scheduler()
{
Logger.Write("Initialising scheduler.... " + DateTime.Now,
"ABSPerformance");
System.Timers.Timer testTimer = new System.Timers.Timer();
testTimer.Enabled = true;
testTimer.Interval = 60 * 1000;
testTimer.Elapsed += new
System.Timers.ElapsedEventHandler(testTimer_Elapse d);
}
private void testTimer_Elapsed(object sender,
System.Timers.ElapsedEventArgs e)
{
if (!DateTime.Now.DayOfWeek.Equals(DayOfWeek.Saturday ) &&
!DateTime.Now.DayOfWeek.Equals(DayOfWeek.Sunday))
{
if (DateTime.Now.Hour.Equals(8) &&
DateTime.Now.Minute.Equals(30))
{
ABSData.executeNonQuery("StructuredCD.sp_ABS_Updat e",
null);
}
}
}
Is there a technical reason why I can't use the scheduler in this way, why
it only works on the first day?
As you have probably guessed, I am new to ASP.NET, so any help would be
appreciated.
Many thanks
Rob