Beispiel #1
0
        /// <summary>
        /// Start the actioner. It will begin processing the entries until stopped.
        /// </summary>
        public void Start()
        {
            CancelTokenSrc?.Dispose( );

            CancelTokenSrc = new CancellationTokenSource();

            if (State == ActionerState.Stopping)
            {
                throw new ActionerStartingWhileStoppingException(Queue.Name ?? "[Unnamed]");
            }

            if (State == ActionerState.Running || State == ActionerState.WaitingForQueue || State == ActionerState.WaitingForTask)
            {
                return;
            }

            if (LoopingThread != null)
            {
                throw new ApplicationException("Attempted to start a loop while another was still running. This should never happen.");
            }

            State = ActionerState.Running;

            LoopingThread = new Thread(ActionLoop)
            {
                Name = $"{ActionLoopTheadPrefix} {Queue.Name}", IsBackground = true
            };
            LoopingThread.Start();
        }
Beispiel #2
0
        private bool _disposedValue; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!_disposedValue)
            {
                if (disposing)
                {
                    Stop(DisposeStopWait);

                    CancelTokenSrc?.Dispose( );
                }

                _disposedValue = true;
            }
        }