other/Scripts/Network/RPCNet/Base/AsyncCollection.cs
/// <summary>Provides a consuming <see cref="T:System.Collections.Generics.IEnumerable{T}"/> for items in the collection.
/// Calling MoveNext on the returned enumerable will block if there is no data available, or will
/// throw an <see cref="System.OperationCanceledException"/> if the <see cref="CancellationToken"/> is canceled.
/// </summary>
/// <param name="cancellationToken">A cancellation token to observe.</param>
/// <returns>An <see cref="T:System.Collections.Generics.IEnumerable{T}"/> that removes and returns items from the collection.</returns>
/// <exception cref="T:System.ObjectDisposedException">The AsyncCollection has been disposed.</exception>
/// <exception cref="OperationCanceledException">If the <see cref="CancellationToken"/> is canceled.</exception>
Provides a consuming  for items in the collection.
Calling MoveNext on the returned enumerable will block if there is no data available, or will
throw an  if the  is canceled.
Provides a consuming for items in the collection . Calling MoveNext on the returned enumerable will block if there is no data available or will throw an if the is canceled .
public IEnumerable<T> GetConsumingEnumerable(CancellationToken cancellationToken)
        {
            CheckDisposed();
            CancellationTokenSource linked =
                CancellationTokenSource.CreateLinkedTokenSource(doneCancellationToken.Token, cancellationToken);
            try
            {
                while (true)
                {
                    if (TryTake(out T result, Timeout.Infinite, linked.Token))
                        yield return result;
                    else
                        break;
                }
            }
            finally
            {
                linked.Dispose();
            }
        }
public IEnumerable < T > GetConsumingEnumerable ( CancellationToken cancellationToken ) { CheckDisposed ( ) ; CancellationTokenSource linked = CancellationTokenSource . CreateLinkedTokenSource ( doneCancellationToken . Token , cancellationToken ) ; try { while ( true ) { if ( TryTake ( out T result , Timeout . Infinite , linked . Token ) ) yield return result ; else break ; } } finally { linked . Dispose ( ) ; } }
Provides a consuming  for items in the collection.
Provides a consuming for items in the collection .
An  that removes and returns items from the collection.
An that removes and returns items from the collection .
The AsyncCollection has been disposed.
The AsyncCollection has been disposed .
If the  is canceled.
If the is canceled .
cancellationToken
CancellationToken
A cancellation token to observe.
A cancellation token to observe .