mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 13:15:07 +00:00
Using monitor instead of mutex for SafeCriticalSection
This commit is contained in:
@@ -5,16 +5,6 @@ namespace ICD.Common.Utils
|
|||||||
{
|
{
|
||||||
public sealed partial class SafeCriticalSection
|
public sealed partial class SafeCriticalSection
|
||||||
{
|
{
|
||||||
private readonly Mutex m_Mutex;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor.
|
|
||||||
/// </summary>
|
|
||||||
public SafeCriticalSection()
|
|
||||||
{
|
|
||||||
m_Mutex = new Mutex();
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -22,7 +12,7 @@ namespace ICD.Common.Utils
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Enter()
|
public void Enter()
|
||||||
{
|
{
|
||||||
m_Mutex.WaitOne();
|
Monitor.Enter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -30,7 +20,7 @@ namespace ICD.Common.Utils
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Leave()
|
public void Leave()
|
||||||
{
|
{
|
||||||
m_Mutex.ReleaseMutex();
|
Monitor.Exit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -41,7 +31,7 @@ namespace ICD.Common.Utils
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public bool TryEnter()
|
public bool TryEnter()
|
||||||
{
|
{
|
||||||
return m_Mutex.WaitOne(0);
|
return Monitor.TryEnter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user