Prevent disposed semaphore exceptions by checking the cancellation token first

This commit is contained in:
Jordan Brown
2020-05-20 23:52:43 -04:00
parent 960d86ba22
commit 499fb37cb7
@@ -19,8 +19,8 @@ namespace Tgstation.Server.Host.Core
{
if (semaphore == null)
throw new ArgumentNullException(nameof(semaphore));
await semaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
cancellationToken.ThrowIfCancellationRequested();
await semaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
return new SemaphoreSlimContext(semaphore);
}