Table of Contents

Method ToBoundedChannelReader

Namespace
Open.Database.Extensions
Assembly
Open.Database.Extensions.Channel.dll

ToBoundedChannelReader<T>(IMappedQuery<T>, int, CancellationToken)

Reads the query into a new bounded channel and returns its reader.

public static ChannelReader<T> ToBoundedChannelReader<T>(this IMappedQuery<T> source, int capacity, CancellationToken cancellationToken = default)

Parameters

source IMappedQuery<T>

The mapped query to read.

capacity int

The most rows the channel holds.

cancellationToken CancellationToken

Cancels the read.

Returns

ChannelReader<T>

The reader of the new channel.

Type Parameters

T

The type of each row.

Remarks

The bound limits the channel, not memory: the query is still read at full speed, and the rows the channel has no room for wait in an internal queue.

Exceptions

ArgumentNullException

source is null.

ArgumentOutOfRangeException

capacity is less than one.

OperationCanceledException

cancellationToken is already canceled.