diff --git a/MPF.Library/Data/ProcessingQueue.cs b/MPF.Library/Data/ProcessingQueue.cs index 4a31c8bd..e98442c3 100644 --- a/MPF.Library/Data/ProcessingQueue.cs +++ b/MPF.Library/Data/ProcessingQueue.cs @@ -17,11 +17,6 @@ namespace MPF.Data /// private readonly Action CustomProcessing; - /// - /// Internal processing task for dequeueing - /// - private readonly Task ProcessingTask; - /// /// Cancellation method for the processing task /// @@ -32,7 +27,7 @@ namespace MPF.Data this.InternalQueue = new ConcurrentQueue(); this.CustomProcessing = customProcessing; this.TokenSource = new CancellationTokenSource(); - this.ProcessingTask = Task.Run(() => ProcessQueue(), this.TokenSource.Token); + Task.Run(() => ProcessQueue(), this.TokenSource.Token); } /// @@ -41,8 +36,6 @@ namespace MPF.Data public void Dispose() { this.TokenSource.Cancel(); - while (!this.ProcessingTask.IsCompleted) ; - this.ProcessingTask.Dispose(); } /// @@ -51,7 +44,8 @@ namespace MPF.Data /// public void Enqueue(T item) { - this.InternalQueue.Enqueue(item); + if (!this.TokenSource.IsCancellationRequested) + this.InternalQueue.Enqueue(item); } ///