SetCancelTokenForStopping() public method

Sets the cancel flag indicating that workers should no longer look for new work to process
public SetCancelTokenForStopping ( ) : void
return void
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (!disposing)
            {
                return;
            }

            if (Interlocked.Increment(ref _disposeCount) != 1)
            {
                return;
            }

            //stop monitor process(es)
            _queueMonitor.Stop();

            //tell the worker to stop
            if (_primaryWorker.IsValueCreated)
            {
                _stopWorker.SetCancelTokenForStopping();
                _stopWorker.StopPrimary(_primaryWorker.Value);

                _primaryWorker.Value.UserException   -= LogUserException;
                _primaryWorker.Value.SystemException -= LogSystemException;
                _primaryWorker.Value.Dispose();
            }
            base.Dispose(true);
        }
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (!disposing)
            {
                return;
            }

            if (Interlocked.Increment(ref _disposeCount) != 1)
            {
                return;
            }

            ShouldWork = false;
            _queueMonitor.Stop();

            if (_primaryWorker.IsValueCreated)
            {
                //stop looking for pending work
                _stopWorker.SetCancelTokenForStopping();

                _stopWorker.StopPrimary(_primaryWorker.Value);

                _primaryWorker.Value.UserException   -= LogUserException;
                _primaryWorker.Value.SystemException -= LogSystemException;
                _primaryWorker.Value.Dispose();
            }
            base.Dispose(true);
        }