Hallo,
I've writed a C# windows service in VS 2003.
This service use a System.Timers.Timer to periodically call some functions
of a web service.
( Some of this functions required minutes to be executed ).
The timer interval is 1 sec, and each functions 'counts' his number of timer
clock to know when it must be executed.
Sometimes happen that the service don't do his works. I stop the service and
watching the log i note thath the timer has stop 'clocking' some hour ago
( i save the last clock datetime in TmrSystem_Elapsed event handler and i
log this value in the service OnStop function ).
Someone have an idea ?
Thanks.
- Dany -
The code ..
private void TmrSystem_Elapsed(object sender, System.Timers.ElapsedEventArgs
e)
{
DtmLastClock = System.DateTime.Now;
if ( NumFunction1_TimerSteps 0 )
{
NumFunction1_StepsCount++;
if ( !BolFunction1_Lock && NumFunction1_StepsCount >=
NumFunction1_TimerSteps )
{
BolFunction1_Lock = true;
NumFunction1_StepsCount = 0;
this.Function1();
BolFunction1_Lock = false;
}
}
if ( NumFunction2_TimerSteps 0 )
{
NumFunction2_StepsCount++;
if ( !BolFunction2_Lock && NumFunction2_StepsCount >=
NumFunction2_TimerSteps )
{
BolFunction2_Lock = true;
NumFunction2_StepsCount = 0;
this.Function2();
BolFunction2_Lock = false;
}
}
}