From db29061ccbc945cf29d0fe4bd733b0914b8092de Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Thu, 4 Jan 2024 22:52:12 +0800 Subject: [PATCH] fixes for support Unity 2020.1.x --- src/ThreadRunner.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ThreadRunner.cs b/src/ThreadRunner.cs index 753d23a..3e57dde 100644 --- a/src/ThreadRunner.cs +++ b/src/ThreadRunner.cs @@ -18,6 +18,8 @@ namespace DCFApixels.DragonECS private static bool _isRunning = false; + private static object _lock = new object(); + private static void ThreadProc(object obj) { int i = (int)obj; @@ -117,9 +119,12 @@ namespace DCFApixels.DragonECS _worker = _nullWorker; if (_catchedExceptions.Count > 0) { - Exception[] exceptions = _catchedExceptions.ToArray(); - _catchedExceptions.Clear(); - throw new AggregateException(exceptions); + lock (_lock) + { + Exception[] exceptions = _catchedExceptions.ToArray(); + _catchedExceptions = new ConcurrentQueue(); + throw new AggregateException(exceptions); + } } }