From 1dc117ac0aaf4f3b3c89970f41a562b589b32e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BAben=20Garcia?= Date: Wed, 14 Feb 2024 02:22:34 +0000 Subject: [PATCH] Fix m_DisposeWaitEvent Before m_DisposeWaitEvent was waiting inside mutex --- OpenMod.Economy/Dispatcher/EconomyDispatcher.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/OpenMod.Economy/Dispatcher/EconomyDispatcher.cs b/OpenMod.Economy/Dispatcher/EconomyDispatcher.cs index db78cb4..f5c67bd 100644 --- a/OpenMod.Economy/Dispatcher/EconomyDispatcher.cs +++ b/OpenMod.Economy/Dispatcher/EconomyDispatcher.cs @@ -41,8 +41,16 @@ public async ValueTask DisposeAsync() return; m_DisposeWaitEvent = new ManualResetEventSlim(); - m_DisposeWaitEvent.Wait(); - m_DisposeWaitEvent.Dispose(); + } + + try + { + m_DisposeWaitEvent?.Wait(); + } + finally + { + m_DisposeWaitEvent?.Dispose(); + m_DisposeWaitEvent = null; } }