MemoryStream.EndRead(IAsyncResult) 方法

定义

等待挂起的异步读取操作完成。Waits for the pending asynchronous read to complete. (请考虑改用 ReadAsync(Byte[], Int32, Int32, CancellationToken)。)(Consider using ReadAsync(Byte[], Int32, Int32, CancellationToken) instead.)

public:
 override int EndRead(IAsyncResult ^ asyncResult);
public override int EndRead (IAsyncResult asyncResult);
override this.EndRead : IAsyncResult -> int
Public Overrides Function EndRead (asyncResult As IAsyncResult) As Integer

参数

asyncResult
IAsyncResult

对要完成的挂起异步请求的引用。The reference to the pending asynchronous request to finish.

返回

从内存流中读取的字节数,介于零 (0) 和所请求的字节数之间。The number of bytes read from the memory stream, between zero (0) and the number of bytes you requested. 仅在内存流结尾返回零 (0),否则在至少有 1 个字节可用之前应一直进行阻止。Returns zero (0) only at the end of the memory stream, otherwise, it should block until at least one byte is available.

异常

asyncResultnullasyncResult is null.

处于挂起状态的读取操作的句柄不可用。A handle to the pending read operation is not available.

- 或 --or-

挂起操作不支持读取。The pending operation does not support reading.

asyncResult 不源于当前内存流的 BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) 方法。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.

注解

有关此方法的其他用法信息,请参阅 EndRead 注释。Refer to the EndRead remarks for additional usage information for this method.

适用于