MemoryStream.EndRead(IAsyncResult) Method

Definition

Waits for the pending asynchronous read to complete. (Consider using ReadAsync(Byte[], Int32, Int32, CancellationToken) instead.)

C#
public override int EndRead(IAsyncResult asyncResult);

Parameters

asyncResult
IAsyncResult

The reference to the pending asynchronous request to finish.

Returns

The number of bytes read from the memory stream, between zero (0) and the number of bytes you requested. Returns zero (0) only at the end of the memory stream, otherwise, it should block until at least one byte is available.

Exceptions

asyncResult is null.

A handle to the pending read operation is not available.

-or-

The pending operation does not support reading.

asyncResult did not originate from a BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) method on the current memory stream.

The stream is closed or an internal error has occurred.

Remarks

Refer to the EndRead remarks for additional usage information for this method.

Applies to

Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.1