wabbajack/Wabbajack.Common/Util/AsyncLock.cs
Timothy Baldridge b181d48722 More test fixes
2020-08-12 22:14:35 -06:00

21 lines
490 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 readonly SemaphoreSlim _lock = new SemaphoreSlim(1, 1);
public async Task<IDisposable> WaitAsync()
{
await _lock.WaitAsync();
return Disposable.Create(() => _lock.Release());
}
}
}