public void Deactivate() { _cancelationToken = true; Wait(); _queue.Cancel(); foreach (var thread in _workerThreads) { thread.Join(); } }
protected void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { if (!_cancelationToken.Exchange(true)) { _queue.Cancel(); _workerThread.Join(); } } _disposed = true; }