Share via


AsyncEnumerableExtensions.Peek<T> Method

Definition

Peeks at the first element of an async enumerable sequence without consuming the sequence.

public static System.Threading.Tasks.ValueTask<(bool HasValue, T First, System.Collections.Generic.IAsyncEnumerable<T> Source)> Peek<T>(this System.Collections.Generic.IAsyncEnumerable<T> source, System.Threading.CancellationToken cancellationToken = default);
static member Peek : System.Collections.Generic.IAsyncEnumerable<'T> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<ValueTuple<bool, 'T, System.Collections.Generic.IAsyncEnumerable<'T>>>
<Extension()>
Public Function Peek(Of T) (source As IAsyncEnumerable(Of T), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of ValueTuple(Of Boolean, T, IAsyncEnumerable(Of T)))

Type Parameters

T

The type of elements in the sequence.

Parameters

source
IAsyncEnumerable<T>

The source async enumerable sequence.

cancellationToken
CancellationToken

A cancellation token to observe while peeking at the sequence.

Returns

A tuple containing a flag indicating if the sequence has a value, the first element, and the complete sequence including the peeked element.

Applies to