CompressionStream.ReadAsync 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.
Overloads
ReadAsync(Memory<Byte>, CancellationToken) | |
ReadAsync(Byte[], Int32, Int32, CancellationToken) |
Asynchronously reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. |
ReadAsync(Memory<Byte>, CancellationToken)
public override System.Threading.Tasks.ValueTask<int> ReadAsync (Memory<byte> destination, System.Threading.CancellationToken cancellationToken = null);
abstract member ReadAsync : Memory<byte> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<int>
override this.ReadAsync : Memory<byte> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<int>
Parameters
- cancellationToken
- CancellationToken
Returns
Applies to
ReadAsync(Byte[], Int32, Int32, CancellationToken)
Asynchronously reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
public override System.Threading.Tasks.Task<int> ReadAsync (byte[] array, int offset, int count, System.Threading.CancellationToken cancellationToken);
abstract member ReadAsync : byte[] * int * int * System.Threading.CancellationToken -> System.Threading.Tasks.Task<int>
override this.ReadAsync : byte[] * int * int * System.Threading.CancellationToken -> System.Threading.Tasks.Task<int>
Parameters
- array
- Byte[]
The array to write the data into.
- offset
- Int32
The byte offset in array at which to begin writing data from the stream.
- count
- Int32
The maximum number of bytes to read.
- cancellationToken
- CancellationToken
The token to monitor for cancellation requests.
Returns
A task that represents the asynchronous read operation. The value of the TResult parameter contains the total number of bytes read into the buffer. The result value can be less than the number of bytes requested if the number of bytes currently available is less than the requested number, or it can be 0 (zero) if the end of the stream has been reached.
Exceptions
array
is null.
offset
or count
is negative.
Either the current stream or the destination stream is disposed.
The current stream does not support reading.