TaskAsyncEnumerableExtensions.WithCancellation<T> Method

Definition

Sets the CancellationToken to be passed to GetAsyncEnumerator(CancellationToken) when iterating.

C#
public static System.Runtime.CompilerServices.ConfiguredCancelableAsyncEnumerable<T> WithCancellation<T>(this System.Collections.Generic.IAsyncEnumerable<T> source, System.Threading.CancellationToken cancellationToken);

Type Parameters

T

The type of the objects being iterated.

Parameters

source
IAsyncEnumerable<T>

The source enumerable being iterated.

cancellationToken
CancellationToken

The CancellationToken to use.

Returns

The configured enumerable.

Applies to

Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.0 (package-provided), 2.1