From 3955d96ea8c92279512a37ee31e7bbbaa6028bc3 Mon Sep 17 00:00:00 2001 From: Ogoun Date: Thu, 30 Jan 2020 21:29:32 +0300 Subject: [PATCH] Update Multiprocessor.cs --- ZeroLevel/Services/Utils/Multiprocessor.cs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/ZeroLevel/Services/Utils/Multiprocessor.cs b/ZeroLevel/Services/Utils/Multiprocessor.cs index 600283c..21c19e0 100644 --- a/ZeroLevel/Services/Utils/Multiprocessor.cs +++ b/ZeroLevel/Services/Utils/Multiprocessor.cs @@ -10,7 +10,7 @@ namespace ZeroLevel.Utils { private BlockingCollection _queue = new BlockingCollection(); private List _threads = new List(); - private bool _is_disposed = false; + private volatile bool _is_disposed = false; private int _tasks_in_progress = 0; public int Count => _queue.Count + _tasks_in_progress; @@ -30,7 +30,7 @@ namespace ZeroLevel.Utils Interlocked.Increment(ref _tasks_in_progress); try { - handler(item); + handler?.Invoke(item); } finally { @@ -76,14 +76,6 @@ namespace ZeroLevel.Utils { _queue.CompleteAdding(); _queue.Dispose(); - foreach (var thread in _threads) - { - try - { - thread.Interrupt(); - } - catch { } - } } catch { } }