From 25d799fe7dd41edead9626a0e7e9251476ed6430 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Mon, 12 Apr 2021 15:13:38 -0400 Subject: [PATCH] fix: Fixed a bug where SafeTimer.Trigger would call the callback twice on NetStandard --- ICD.Common.Utils.Tests/Timers/SafeTimerTest.cs | 8 +++++--- ICD.Common.Utils/Timers/SafeTimer.cs | 1 - 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ICD.Common.Utils.Tests/Timers/SafeTimerTest.cs b/ICD.Common.Utils.Tests/Timers/SafeTimerTest.cs index 9984ce9..603e969 100644 --- a/ICD.Common.Utils.Tests/Timers/SafeTimerTest.cs +++ b/ICD.Common.Utils.Tests/Timers/SafeTimerTest.cs @@ -49,12 +49,14 @@ namespace ICD.Common.Utils.Tests.Timers [Test] public void TriggerTest() { - bool called = false; - SafeTimer timer = SafeTimer.Stopped(() => called = true); + int called = 0; + SafeTimer timer = SafeTimer.Stopped(() => called++); timer.Trigger(); - Assert.IsTrue(called); + ThreadingUtils.Sleep(50); + + Assert.AreEqual(1, called); timer.Dispose(); } diff --git a/ICD.Common.Utils/Timers/SafeTimer.cs b/ICD.Common.Utils/Timers/SafeTimer.cs index 1ed80bd..9e4df8b 100644 --- a/ICD.Common.Utils/Timers/SafeTimer.cs +++ b/ICD.Common.Utils/Timers/SafeTimer.cs @@ -112,7 +112,6 @@ namespace ICD.Common.Utils.Timers m_Timer.Reset(); #else m_Timer.Change(0, m_RepeatPeriod); - m_Callback(); #endif }