From 6224e7c8cb484e63142cfc1877a07525d5783740 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Sun, 1 Oct 2017 19:13:44 -0400 Subject: [PATCH] Using monitor instead of mutex for SafeCriticalSection --- ICD.Common.Utils/SafeCriticalSection.Standard.cs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/ICD.Common.Utils/SafeCriticalSection.Standard.cs b/ICD.Common.Utils/SafeCriticalSection.Standard.cs index d337d72..9c14105 100644 --- a/ICD.Common.Utils/SafeCriticalSection.Standard.cs +++ b/ICD.Common.Utils/SafeCriticalSection.Standard.cs @@ -5,16 +5,6 @@ namespace ICD.Common.Utils { public sealed partial class SafeCriticalSection { - private readonly Mutex m_Mutex; - - /// - /// Constructor. - /// - public SafeCriticalSection() - { - m_Mutex = new Mutex(); - } - #region Methods /// @@ -22,7 +12,7 @@ namespace ICD.Common.Utils /// public void Enter() { - m_Mutex.WaitOne(); + Monitor.Enter(this); } /// @@ -30,7 +20,7 @@ namespace ICD.Common.Utils /// public void Leave() { - m_Mutex.ReleaseMutex(); + Monitor.Exit(this); } /// @@ -41,7 +31,7 @@ namespace ICD.Common.Utils /// public bool TryEnter() { - return m_Mutex.WaitOne(0); + return Monitor.TryEnter(this); } #endregion