Expose SemaphoreSlim.Acquire with CancellationToken

This commit is contained in:
2025-05-20 12:25:36 +02:00
parent bae28b2552
commit af1dfd6751
4 changed files with 14 additions and 3 deletions
@@ -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);
}
}