#if !SIMPLSHARP using System.Threading; namespace ICD.Common.Utils { public sealed partial class SafeCriticalSection { private readonly Mutex m_Mutex; /// /// Constructor. /// public SafeCriticalSection() { m_Mutex = new Mutex(); } #region Methods /// /// Block until ownership of the critical section can be obtained. /// public void Enter() { m_Mutex.WaitOne(); } /// /// Release ownership of the critical section. /// public void Leave() { m_Mutex.ReleaseMutex(); } /// /// Attempt to enter the critical section without blocking. /// /// /// True, calling thread has ownership of the critical section; otherwise, false. /// public bool TryEnter() { return m_Mutex.WaitOne(0); } #endregion } } #endif