Share via


JsonRpcExtensions.WithPrefetchAsync<T> Method

Definition

Preloads an IAsyncEnumerable<T> with a cache of pre-enumerated items for inclusion in the initial transmission of the enumerable over an RPC channel.

public static System.Threading.Tasks.ValueTask<System.Collections.Generic.IAsyncEnumerable<T>> WithPrefetchAsync<T> (this System.Collections.Generic.IAsyncEnumerable<T> enumerable, int count, System.Threading.CancellationToken cancellationToken = default);
static member WithPrefetchAsync : System.Collections.Generic.IAsyncEnumerable<'T> * int * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<System.Collections.Generic.IAsyncEnumerable<'T>>
<Extension()>
Public Function WithPrefetchAsync(Of T) (enumerable As IAsyncEnumerable(Of T), count As Integer, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of IAsyncEnumerable(Of T))

Type Parameters

T

The type of item in the collection.

Parameters

enumerable
IAsyncEnumerable<T>

The sequence to pre-fetch items from.

count
Int32

The number of items to pre-fetch. If this value is larger than the number of elements in the enumerable, all values will be pre-fetched.

cancellationToken
CancellationToken

A cancellation token.

Returns

A decorated IAsyncEnumerable<T> object that is specially prepared for processing by JSON-RPC with the preloaded values.

Applies to