wabbajack/Wabbajack.Common/SemaphoreSlimExtensions.cs

15 lines
352 B
C#
Raw Normal View History

2021-11-27 18:31:35 +00:00
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());
}
}