Share via


PipeMessageHandler.ReadAtLeastAsync(Int32, Boolean, CancellationToken) Method

Definition

Reads from the Reader until at least a specified number of bytes are available.

protected System.Threading.Tasks.ValueTask<System.IO.Pipelines.ReadResult> ReadAtLeastAsync (int requiredBytes, bool allowEmpty, System.Threading.CancellationToken cancellationToken);
member this.ReadAtLeastAsync : int * bool * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<System.IO.Pipelines.ReadResult>
Protected Function ReadAtLeastAsync (requiredBytes As Integer, allowEmpty As Boolean, cancellationToken As CancellationToken) As ValueTask(Of ReadResult)

Parameters

requiredBytes
Int32

The number of bytes that must be available.

allowEmpty
Boolean

true to allow returning 0 bytes if the end of the stream is encountered before any bytes are read.

cancellationToken
CancellationToken

A cancellation token.

Returns

The ReadResult containing at least requiredBytes bytes.

Exceptions

Thrown if IsCompleted before we have requiredBytes bytes. Not thrown if 0 bytes were read and allowEmpty is true.

Applies to