private static async Task _enumerate(AsyncEnumerator <TSource> .Yield yield, WhereContext <TSource> context) { using (var enumerator = await context.Source.GetAsyncEnumeratorAsync(yield.CancellationToken).ConfigureAwait(false)) { while (await enumerator.MoveNextAsync(yield.CancellationToken).ConfigureAwait(false)) { if (context.Predicate(enumerator.Current)) { await yield.ReturnAsync(enumerator.Current).ConfigureAwait(false); } } } }
private static async Task _enumerate(AsyncEnumerator <TSource> .Yield yield, WhereContext <TSource> context) { try { while (await context.Source.MoveNextAsync(yield.CancellationToken).ConfigureAwait(false)) { if (context.Predicate(context.Source.Current)) { await yield.ReturnAsync(context.Source.Current).ConfigureAwait(false); } } } finally { if (context.DisposeSource) { context.Source.Dispose(); } } }