Update Multiprocessor.cs

pull/1/head
Ogoun 5 years ago
parent 10934e3ca1
commit 3955d96ea8

@ -10,7 +10,7 @@ namespace ZeroLevel.Utils
{ {
private BlockingCollection<T> _queue = new BlockingCollection<T>(); private BlockingCollection<T> _queue = new BlockingCollection<T>();
private List<Thread> _threads = new List<Thread>(); private List<Thread> _threads = new List<Thread>();
private bool _is_disposed = false; private volatile bool _is_disposed = false;
private int _tasks_in_progress = 0; private int _tasks_in_progress = 0;
public int Count => _queue.Count + _tasks_in_progress; public int Count => _queue.Count + _tasks_in_progress;
@ -30,7 +30,7 @@ namespace ZeroLevel.Utils
Interlocked.Increment(ref _tasks_in_progress); Interlocked.Increment(ref _tasks_in_progress);
try try
{ {
handler(item); handler?.Invoke(item);
} }
finally finally
{ {
@ -76,14 +76,6 @@ namespace ZeroLevel.Utils
{ {
_queue.CompleteAdding(); _queue.CompleteAdding();
_queue.Dispose(); _queue.Dispose();
foreach (var thread in _threads)
{
try
{
thread.Interrupt();
}
catch { }
}
} }
catch { } catch { }
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.