mirror of
https://github.com/AlexMacocian/SystemExtensions.git
synced 2026-07-16 14:39:28 +00:00
Expose SemaphoreSlim.Acquire with CancellationToken
This commit is contained in:
@@ -21,4 +21,10 @@ public readonly struct SemaphoreSlimContext : IDisposable
|
||||
await semaphore.ThrowIfNull(nameof(semaphore)).WaitAsync();
|
||||
return new SemaphoreSlimContext(semaphore);
|
||||
}
|
||||
|
||||
public static async Task<SemaphoreSlimContext> Create(SemaphoreSlim semaphore, CancellationToken cancellationToken)
|
||||
{
|
||||
await semaphore.ThrowIfNull(nameof(semaphore)).WaitAsync(cancellationToken);
|
||||
return new SemaphoreSlimContext(semaphore);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user