wabbajack/Wabbajack.Common/Util/AsyncLock.cs
2019-12-21 18:17:56 -06:00

22 lines
477 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Disposables;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Wabbajack.Common
{
public class AsyncLock
{
private SemaphoreSlim _lock = new SemaphoreSlim(1, 1);
public async Task<IDisposable> Wait()
{
await _lock.WaitAsync();
return Disposable.Create(() => _lock.Release());
}
}
}