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_Sta rt()
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_Sta rt(object sender, EventArgs e)
{
Scheduler sch = new Scheduler();
}
public Scheduler()
{
Logger.Write("I nitialising scheduler.... " + DateTime.Now,
"ABSPerformance ");
System.Timers.T imer testTimer = new System.Timers.T imer();
testTimer.Enabl ed = true;
testTimer.Inter val = 60 * 1000;
testTimer.Elaps ed += new
System.Timers.E lapsedEventHand ler(testTimer_E lapsed);
}
private void testTimer_Elaps ed(object sender,
System.Timers.E lapsedEventArgs e)
{
if (!DateTime.Now. DayOfWeek.Equal s(DayOfWeek.Sat urday) &&
!DateTime.Now.D ayOfWeek.Equals (DayOfWeek.Sund ay))
{
if (DateTime.Now.H our.Equals(8) &&
DateTime.Now.Mi nute.Equals(30) )
{
ABSData.execute NonQuery("Struc turedCD.sp_ABS_ Update",
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
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_Sta rt()
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_Sta rt(object sender, EventArgs e)
{
Scheduler sch = new Scheduler();
}
public Scheduler()
{
Logger.Write("I nitialising scheduler.... " + DateTime.Now,
"ABSPerformance ");
System.Timers.T imer testTimer = new System.Timers.T imer();
testTimer.Enabl ed = true;
testTimer.Inter val = 60 * 1000;
testTimer.Elaps ed += new
System.Timers.E lapsedEventHand ler(testTimer_E lapsed);
}
private void testTimer_Elaps ed(object sender,
System.Timers.E lapsedEventArgs e)
{
if (!DateTime.Now. DayOfWeek.Equal s(DayOfWeek.Sat urday) &&
!DateTime.Now.D ayOfWeek.Equals (DayOfWeek.Sund ay))
{
if (DateTime.Now.H our.Equals(8) &&
DateTime.Now.Mi nute.Equals(30) )
{
ABSData.execute NonQuery("Struc turedCD.sp_ABS_ Update",
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
Comment