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

            try
            {
                UpdateLastExecutionTime();
                Initialize();
                var oldState = Interlocked.CompareExchange(ref v_executionState, StartedState, NotStartedState);
                if (oldState != NotStartedState)
                {
                    ThrowHelper.ThrowInvalidOperationException_ExecutionState0(oldState);
                }
                _loopRunStart.Set();
                _ = _loop.Run(uv_run_mode.UV_RUN_DEFAULT);
            }
            catch (Exception ex)
            {
                _loopRunStart.Set();
                Logger.LoopRunDefaultError(_thread, handle, ex);
                _ = _terminationCompletionSource.TrySetException(ex);
            }
            finally
            {
                if (Logger.InfoEnabled)
                {
                    Logger.LoopThreadFinished(_thread, handle);
                }
                CleanupAndTerminate();
            }
        }