void mainTimer__Elapsed(object sender)
{
lock (_iterationLock)
{
IterationResult result = null;
try
{
PauseTimer();
_iterationRunning = true;
CheckIn();
result = OnWaitingPeriodElapsedAdvanced();
_iterationRunning = false;
CheckIn();
}
catch (Exception ex)
{
LogProvider.ErrorFormat("Unhandled exception executing task '{0}'", ex, Name);
}
finally
{
try
{
_iterationRunning = false;
ResumeTimer(result ?? new IterationResult());
}
catch (Exception ex)
{
LogProvider.ErrorFormat("Unhandled exception resuming task '{0}'", ex, Name);
if (IsRunning)
ResetTimer();
}
}
}
}