TaskAsyncEnumerableExtensions.ToBlockingEnumerable<T> Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應