private void LoopCore()
        {
            try
            {
                _ = CompareAndSetExecutionState(NotStartedState, StartedState);

                bool success = false;
                UpdateLastExecutionTime();
                try
                {
                    Run();
                    success = true;
                }
                catch (Exception exc)
                {
                    Logger.UnexpectedExceptionFromAnEventExecutor(exc);
                }
                finally
                {
                    CleanupAndTerminate(success);
                }
            }
            catch (Exception ex)
            {
                Logger.ExecutionLoopFailed(_thread, ex);
                SetExecutionState(TerminatedState);
                _ = _terminationCompletionSource.TrySetException(ex);
            }
        }
예제 #2
0
 void LoopCore()
 {
     try
     {
         _ = Interlocked.CompareExchange(ref v_executionState, ST_STARTED, ST_NOT_STARTED);
         while (!ConfirmShutdown())
         {
             _ = RunAllTasks(_preciseBreakoutInterval);
         }
         CleanupAndTerminate(true);
     }
     catch (Exception ex)
     {
         Logger.ExecutionLoopFailed(_thread, ex);
         _ = Interlocked.Exchange(ref v_executionState, ST_TERMINATED);
         _ = _terminationCompletionSource.TrySetException(ex);
     }
 }