示例#1
0
        private void StartLoop()
        {
            IntPtr handle = _loop.Handle;

            try
            {
                bool success = false;
                try
                {
                    UpdateLastExecutionTime();
                    Initialize();
                    if (!CompareAndSetExecutionState(NotStartedState, StartedState))
                    {
                        ThrowHelper.ThrowInvalidOperationException_ExecutionState0(NotStartedState);
                    }
                    _loopRunStart.Set();
                    _       = _loop.Run(uv_run_mode.UV_RUN_DEFAULT);
                    success = true;
                }
                catch (Exception ex)
                {
                    _loopRunStart.Set();
                    TrySetExecutionState(TerminatedState);
                    Logger.LoopRunDefaultError(InnerThread, handle, ex);
                }
                finally
                {
                    if (Logger.InfoEnabled)
                    {
                        Logger.LoopThreadFinished(InnerThread, handle);
                    }
                    CleanupAndTerminate(success);
                }
            }
            catch (Exception exc)
            {
                _ = TerminationCompletionSource.TrySetException(exc);
            }
        }
示例#2
0
 public override void ExceptionCaught(Exception ex)
 {
     State = PipelineState.Exception;
     OnException(ex);
     TerminationCompletionSource.TrySetException(ex);
 }