Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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.
ReadExactlyAsync(Memory<Byte>, CancellationToken) |
Asynchronously reads bytes from the current stream, advances the position within the stream until the |
ReadExactlyAsync(Byte[], Int32, Int32, CancellationToken) |
Asynchronously reads |
Asynchronously reads bytes from the current stream, advances the position within the stream until the buffer
is filled, and monitors cancellation requests.
public System.Threading.Tasks.ValueTask ReadExactlyAsync(Memory<byte> buffer, System.Threading.CancellationToken cancellationToken = default);
member this.ReadExactlyAsync : Memory<byte> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask
Public Function ReadExactlyAsync (buffer As Memory(Of Byte), Optional cancellationToken As CancellationToken = Nothing) As ValueTask
The token to monitor for cancellation requests.
A task that represents the asynchronous read operation.
The end of the stream is reached before filling the buffer
.
The cancellation token was canceled. This exception is stored into the returned task.
When buffer
is empty, this read operation will be completed without waiting for available data in the stream.
Product | Versions |
---|---|
.NET | 7, 8, 9, 10 |
Asynchronously reads count
number of bytes from the current stream, advances the position within the stream, and monitors cancellation requests.
public System.Threading.Tasks.ValueTask ReadExactlyAsync(byte[] buffer, int offset, int count, System.Threading.CancellationToken cancellationToken = default);
member this.ReadExactlyAsync : byte[] * int * int * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask
Public Function ReadExactlyAsync (buffer As Byte(), offset As Integer, count As Integer, Optional cancellationToken As CancellationToken = Nothing) As ValueTask
The buffer to write the data into.
The byte offset in buffer
at which to begin writing data from the stream.
The number of bytes to be read from the current stream.
The token to monitor for cancellation requests.
A task that represents the asynchronous read operation.
buffer
is null
.
offset
is outside the bounds of buffer
.
-or-
count
is negative.
-or-
The range specified by the combination of offset
and count
exceeds the
length of buffer
.
The end of the stream is reached before reading count
number of bytes.
The cancellation token was canceled. This exception is stored into the returned task.
When count
is 0 (zero), this read operation will be completed without waiting for available data in the stream.
This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by ReadExactly(Byte[], Int32, Int32).
Product | Versions |
---|---|
.NET | 7, 8, 9, 10 |
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in