Open sandboxFocus

Method BufferToListAsync

BufferToListAsync<T>(IAsyncEnumerator<T>, CancellationToken)

Evaluates an IAsyncEnumerator<T>, stores the result into an AsyncEnumerableList<T> and returns the list. If the enumerator is already an AsyncEnumerableList<T> enumerator, returns the parent AsyncEnumerableList<T>. The intended side effect of this method is to completely evaluate the input enumerator.

Declaration
public static ValueTask<AsyncEnumerableList<T>> BufferToListAsync<T>(this IAsyncEnumerator<T> enumerator, CancellationToken cancellationToken = default)
Parameters
Type Name Description
IAsyncEnumerator<T> enumerator

An enumerator.

CancellationToken cancellationToken

A cancellation token.

Returns
Type Description
ValueTask<AsyncEnumerableList<T>>

An AsyncEnumerableList<T> made from the items of enumerator, or the parent AsyncEnumerableList<T> object if the enumerator object itself it is already an AsyncEnumerableList<T> enumerator.

Type Parameters
Name Description
T