Redigera

Dela via


TaskAsyncEnumerableExtensions.ToBlockingEnumerable<T> Method

Definition

Converts an IAsyncEnumerable<T> instance into an IEnumerable<T> that enumerates elements in a blocking manner.

[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public static System.Collections.Generic.IEnumerable<T> ToBlockingEnumerable<T> (this System.Collections.Generic.IAsyncEnumerable<T> source, System.Threading.CancellationToken cancellationToken = default);
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
static member ToBlockingEnumerable : System.Collections.Generic.IAsyncEnumerable<'T> * System.Threading.CancellationToken -> seq<'T>
<Extension()>
Public Function ToBlockingEnumerable(Of T) (source As IAsyncEnumerable(Of T), Optional cancellationToken As CancellationToken = Nothing) As IEnumerable(Of T)

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

An IEnumerable<T> instance that enumerates the source IAsyncEnumerable<T> in a blocking manner.

Attributes

Remarks

This method is implemented by using deferred execution. The underlying IAsyncEnumerable<T> will not be enumerated unless the returned IEnumerable<T> is enumerated by calling its GetEnumerator() method. Async enumeration does not happen in the background; each MoveNext call will invoke the underlying MoveNextAsync() exactly once.

Applies to