From 72fd823643acfa8bfbe5a41fdd9c498e1f536325 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Thu, 7 Feb 2019 17:13:25 -0500 Subject: [PATCH] test: Fixing unit tests --- ICD.Common.Utils/Collections/RateLimitedEventQueue.cs | 11 ++++++++++- ICD.Common.Utils/Timers/SafeTimer.cs | 7 ++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ICD.Common.Utils/Collections/RateLimitedEventQueue.cs b/ICD.Common.Utils/Collections/RateLimitedEventQueue.cs index 62eee2b..dc4708e 100644 --- a/ICD.Common.Utils/Collections/RateLimitedEventQueue.cs +++ b/ICD.Common.Utils/Collections/RateLimitedEventQueue.cs @@ -56,7 +56,16 @@ namespace ICD.Common.Utils.Collections { OnItemDequeued = null; - m_DequeueTimer.Dispose(); + m_QueueSection.Enter(); + + try + { + m_DequeueTimer.Dispose(); + } + finally + { + m_QueueSection.Leave(); + } } /// diff --git a/ICD.Common.Utils/Timers/SafeTimer.cs b/ICD.Common.Utils/Timers/SafeTimer.cs index 1047f7d..5470846 100644 --- a/ICD.Common.Utils/Timers/SafeTimer.cs +++ b/ICD.Common.Utils/Timers/SafeTimer.cs @@ -85,12 +85,12 @@ namespace ICD.Common.Utils.Timers if (IsDisposed) return; + IsDisposed = true; + Stop(); m_Timer.Dispose(); m_Callback = null; - - IsDisposed = true; } /// @@ -160,7 +160,8 @@ namespace ICD.Common.Utils.Timers // Essentially the meat of this class. There's some weirdness with the garbage collector where // the reference to the timer will be cleared, and eventually the CTimer will call the callback // despite being stopped/disposed. - if (m_Timer == null + if (IsDisposed || + m_Timer == null #if SIMPLSHARP || m_Timer.Disposed #endif