/// <summary> /// Creates an enumerator that iterates through a collection asynchronously /// </summary> /// <param name="cancellationToken">A cancellation token to cancel creation of the enumerator in case if it takes a lot of time</param> /// <returns>Returns a task with the created enumerator as result on completion</returns> Task <IAsyncEnumerator> IAsyncEnumerable.GetAsyncEnumeratorAsync(CancellationToken cancellationToken) { var enumerator = new AsyncEnumeratorWithState <TItem, TState>(_enumerationFunction, State); return(Task.FromResult <IAsyncEnumerator>(enumerator)); }
/// <summary> /// Creates an enumerator that iterates through a collection asynchronously /// </summary> /// <param name="cancellationToken">A cancellation token to cancel creation of the enumerator in case if it takes a lot of time</param> /// <returns>Returns a task with the created enumerator as result on completion</returns> public virtual Task <IAsyncEnumerator <TItem> > GetAsyncEnumeratorAsync(CancellationToken cancellationToken = default) { var enumerator = new AsyncEnumeratorWithState <TItem, TState>(_enumerationFunction, State); return(Task.FromResult <IAsyncEnumerator <TItem> >(enumerator)); }