/// <summary> /// Disposes all dispatcher resources and remaining tasks. /// </summary> public override void Dispose() { while (true) { lock (TaskList) { if (TaskList.Count != 0) { currentTask = TaskList[0]; TaskList.RemoveAt(0); } else { break; } } currentTask.Dispose(); } DataEvent.Close(); DataEvent = null; if (currentDispatcher == this) { currentDispatcher = null; } if (mainDispatcher == this) { mainDispatcher = null; } }
/// <summary> /// Disposes all dispatcher resources and remaining tasks. /// </summary> public override void Dispose() { while (true) { lock (TaskListSyncRoot) { if (TaskList.Count != 0) { _currentTask = TaskList.Dequeue(); } else { break; } } _currentTask.Dispose(); } DataEvent.Close(); DataEvent = null; if (CurrentDispatcher == this) { CurrentDispatcher = null; } if (MainDispatcher == this) { MainDispatcher = null; } }
/// <summary> /// Disposes all TaskDistributor, worker threads, resources and remaining tasks. /// </summary> public override void Dispose() { if (_isDisposed) { return; } while (true) { CustomTask currentTask; lock (TaskListSyncRoot) { if (TaskList.Count != 0) { currentTask = TaskList.Dequeue(); } else { break; } } currentTask.Dispose(); } lock (_workerThreads) { foreach (var thread in _workerThreads) { thread.Dispose(); } _workerThreads = new TaskWorker[0]; } DataEvent.Close(); DataEvent = null; if (MainNoThrow == this) { MainNoThrow = null; } _isDisposed = true; }
/// <summary> /// Disposes all TaskDistributor, worker threads, resources and remaining tasks. /// </summary> public override void Dispose() { while (true) { TaskBase currentTask; lock (TaskList) { if (TaskList.Count != 0) { currentTask = TaskList[0]; TaskList.RemoveAt(0); } else { break; } } currentTask.Dispose(); } lock (workerThreads) { foreach (TaskWorker t in workerThreads) { t.Dispose(); } workerThreads = new TaskWorker[0]; } DataEvent.Close(); DataEvent = null; if (mainTaskDistributor == this) { mainTaskDistributor = null; } }