wabbajack/Wabbajack.Common/SemaphoreSlimExtensions.cs
2021-11-27 11:31:35 -07:00

15 lines
352 B
C#

using System;
using System.Reactive.Disposables;
using System.Threading;
using System.Threading.Tasks;
namespace Wabbajack.Common;
public static class SemaphoreSlimExtensions
{
public static async Task<IDisposable> Lock(this SemaphoreSlim slim)
{
await slim.WaitAsync();
return Disposable.Create(() => slim.Release());
}
}