Custom options to control the repeating operation flow from a result of an iteration.
Esempio n. 1
0
 private void ResumeTimer(IterationResult result)
 {
     if (_disposed)
     {
         throw new ObjectDisposedException("WorkerRole");
     }
     lock (_timerLock)
     {
         var waitSeconds = result.NextWaitingPeriodSeconds > 1
             ? result.NextWaitingPeriodSeconds
             : Math.Max(1, WaitingPeriodSeconds);
         var duration = TimeSpan.FromSeconds(waitSeconds);
         _mainTimer.Change(duration, duration);
         _nextIterationTimestamp = DateTime.UtcNow.AddSeconds(waitSeconds);
         CheckIn();
     }
 }
Esempio n. 2
0
 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();
                 }
             }
         }
     }
 }
 private void ResumeTimer(IterationResult result)
 {
     if (_disposed)
         throw new ObjectDisposedException("WorkerRole");
     lock (_timerLock)
     {
         var waitSeconds = result.NextWaitingPeriodSeconds > 1
             ? result.NextWaitingPeriodSeconds
             : Math.Max(1, WaitingPeriodSeconds);
         var duration = TimeSpan.FromSeconds(waitSeconds);
         _mainTimer.Change(duration, duration);
         _nextIterationTimestamp = DateTime.UtcNow.AddSeconds(waitSeconds);
         CheckIn();
     }
 }