mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-17 21:37:43 +01:00
fix: lock profile manager while changing state
This commit is contained in:
parent
3d47e05ab0
commit
28e9d5f156
5 changed files with 77 additions and 43 deletions
29
Dalamud/Utility/ScopedSyncRoot.cs
Normal file
29
Dalamud/Utility/ScopedSyncRoot.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace Dalamud.Utility;
|
||||
|
||||
/// <summary>
|
||||
/// Scope for plugin list locks.
|
||||
/// </summary>
|
||||
public class ScopedSyncRoot : IDisposable
|
||||
{
|
||||
private readonly object lockObj;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ScopedSyncRoot"/> class.
|
||||
/// </summary>
|
||||
/// <param name="lockObj">The object to lock.</param>
|
||||
public ScopedSyncRoot(object lockObj)
|
||||
{
|
||||
this.lockObj = lockObj;
|
||||
Monitor.Enter(lockObj);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
Monitor.Exit(this.lockObj);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue