fix: lock profile manager while changing state

This commit is contained in:
goat 2023-06-20 19:20:08 +02:00
parent 3d47e05ab0
commit 28e9d5f156
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
5 changed files with 77 additions and 43 deletions

View 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);
}
}