コード例 #1
0
 private static async Task _enumerate(AsyncEnumerator <TResult> .Yield yield, SelectContext <TSource, TResult> context)
 {
     using (var enumerator = await context.Source.GetAsyncEnumeratorAsync(yield.CancellationToken).ConfigureAwait(false))
     {
         while (await enumerator.MoveNextAsync(yield.CancellationToken).ConfigureAwait(false))
         {
             await yield.ReturnAsync(context.Selector(enumerator.Current)).ConfigureAwait(false);
         }
     }
 }
コード例 #2
0
 private static async Task _enumerate(AsyncEnumerator <TResult> .Yield yield, SelectContext <TSource, TResult> context)
 {
     try
     {
         while (await context.Source.MoveNextAsync(yield.CancellationToken).ConfigureAwait(false))
         {
             await yield.ReturnAsync(context.Selector(context.Source.Current)).ConfigureAwait(false);
         }
     }
     finally
     {
         if (context.DisposeSource)
         {
             context.Source.Dispose();
         }
     }
 }