mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-14 04:58:33 +00:00
Using monitor instead of mutex for SafeCriticalSection
This commit is contained in:
parent
176993b130
commit
6224e7c8cb
1 changed files with 3 additions and 13 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue