Пример #1
0
        public void Deactivate()
        {
            _cancelationToken = true;

            Wait();

            _queue.Cancel();
            foreach (var thread in _workerThreads)
            {
                thread.Join();
            }
        }
Пример #2
0
        protected void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                if (!_cancelationToken.Exchange(true))
                {
                    _queue.Cancel();
                    _workerThread.Join();
                }
            }

            _disposed = true;
        }