PipeMessageHandler.ReadAtLeastAsync(Int32, Boolean, CancellationToken) 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.
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 IsCanceled.
Thrown if IsCompleted before we have requiredBytes
bytes.
Not thrown if 0 bytes were read and allowEmpty
is true
.