HttpClientUtils/ChangeableSemaphoreSlim.cs
/// <summary>
/// Asynchronously waits to enter the <see cref="ChangeableSemaphoreSlim"/>,
/// using a 32-bit signed integer to measure the time interval, 
/// while observing a <see cref="T:System.Threading.CancellationToken"/>.
/// </summary>
/// <param name="cancellationToken">The <see cref="T:System.Threading.CancellationToken"/> to observe.</param>
/// <returns>
/// A task that will complete with a result of true if the current thread successfully entered 
/// the <see cref="ChangeableSemaphoreSlim"/>, otherwise with a result of false.
/// </returns>
/// <exception cref="T:System.ObjectDisposedException">The current instance has already been
/// disposed.</exception>
Asynchronously waits to enter the ,
using a 32-bit signed integer to measure the time interval,
while observing a .
Asynchronously waits to enter the using a 32 - bit signed integer to measure the time interval while observing a .
public Task<bool> WaitAsync(CancellationToken cancellationToken)
		{
			CheckDispose();
			if (cancellationToken.IsCancellationRequested)
				return Task.FromCanceled<bool>(cancellationToken);
			lock (_mLockObjAndDisposed)
			{
				if (_mAvailableCount > 0)
				{
					Interlocked.Decrement(ref _mAvailableCount);
					return STrueTask;
				}
				var asyncWaiter = CreateAndAddAsyncWaiter();
				return asyncWaiter.Task;
			}
		}
public Task < bool > WaitAsync ( CancellationToken cancellationToken ) { CheckDispose ( ) ; if ( cancellationToken . IsCancellationRequested ) return Task . FromCanceled < bool > ( cancellationToken ) ; lock ( _mLockObjAndDisposed ) { if ( _mAvailableCount > 0 ) { Interlocked . Decrement ( ref _mAvailableCount ) ; return STrueTask ; } var asyncWaiter = CreateAndAddAsyncWaiter ( ) ; return asyncWaiter . Task ; } }
Asynchronously waits to enter the ,
using a 32-bit signed integer to measure the time interval,
while observing a .
Asynchronously waits to enter the using a 32 - bit signed integer to measure the time interval while observing a .
// Bail early for cancellation // If there are counts available, allow this waiter to succeed. // If there aren't, create and return a task to the caller. // The task will be completed either when they've successfully acquired // the semaphore or when the timeout expired or cancellation was requested.
A task that will complete with a result of true if the current thread successfully entered
the , otherwise with a result of false.
A task that will complete with a result of true if the current thread successfully entered the otherwise with a result of false .
The current instance has already been
disposed.
The current instance has already been disposed .
cancellationToken
CancellationToken
The  to observe.
The to observe .