Open sandboxFocus

Method BufferAsync

BufferAsync<T>(IAsyncEnumerable<T>, CancellationToken)

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

Declaration
public static ValueTask<AsyncEnumerableList<T>> BufferAsync<T>(this IAsyncEnumerable<T> enumerable, CancellationToken cancellationToken = default)
Parameters
Type Name Description
IAsyncEnumerable<T> enumerable

An enumerable.

CancellationToken cancellationToken
Returns
Type Description
ValueTask<AsyncEnumerableList<T>>

A AsyncEnumerableList<T> made from the items of enumerable, or the enumerable object itself it is already an AsyncEnumerableList<T>.

Type Parameters
Name Description
T

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

Evaluates an IAsyncEnumerator<T>, stores the result into an AsyncEnumerableList<T> and returns a resettable async enumerator for this object. If the enumerator is already buffered, resets it and returns the same instance. The intended side effect of this method is to completely evaluate the input enumerator.

Declaration
public static ValueTask<RunTimeAspectHelper.AsyncEnumerator<T>> BufferAsync<T>(this IAsyncEnumerator<T> enumerator, CancellationToken cancellationToken = default)
Parameters
Type Name Description
IAsyncEnumerator<T> enumerator

An enumerator.

CancellationToken cancellationToken
Returns
Type Description
ValueTask<RunTimeAspectHelper.AsyncEnumerator<T>>

An RunTimeAspectHelper.AsyncEnumerator<T> that supports Reset().

Type Parameters
Name Description
T