コード例 #1
0
            private static async Task _enumerate(AsyncEnumerator <TSource> .Yield yield, SkipWhileContext <TSource> context)
            {
                using (var enumerator = await context.Source.GetAsyncEnumeratorAsync(yield.CancellationToken).ConfigureAwait(false))
                {
                    var yielding = false;
                    while (await enumerator.MoveNextAsync(yield.CancellationToken).ConfigureAwait(false))
                    {
                        if (!yielding && !context.Predicate(enumerator.Current))
                        {
                            yielding = true;
                        }

                        if (yielding)
                        {
                            await yield.ReturnAsync(enumerator.Current).ConfigureAwait(false);
                        }
                    }
                }
            }
コード例 #2
0
            private static async Task _enumerate(AsyncEnumerator <TSource> .Yield yield, SkipWhileContext <TSource> context)
            {
                try
                {
                    var yielding = false;
                    while (await context.Source.MoveNextAsync(yield.CancellationToken).ConfigureAwait(false))
                    {
                        if (!yielding && !context.Predicate(context.Source.Current))
                        {
                            yielding = true;
                        }

                        if (yielding)
                        {
                            await yield.ReturnAsync(context.Source.Current).ConfigureAwait(false);
                        }
                    }
                }
                finally
                {
                    if (context.DisposeSource)
                    {
                        context.Source.Dispose();
                    }
                }
            }