CryptoStream.EndRead(IAsyncResult) 方法


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

 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



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


从流中读取的字节数,介于零 (0) 和所请求的字节数之间。The number of bytes read from the stream, between zero (0) and the number of bytes you requested. 流仅在流的末尾才返回 (0);否则,在至少一个字节可用之前流将阻塞。Streams return zero (0) only at the end of the stream, otherwise, they 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 stream.

流已关闭或出现了内部错误。The stream is closed or an internal error has occurred.


在 .NET Framework 4 和更早的版本中,您必须使用 BeginReadEndRead 之类的方法来实现异步 I/O 操作。In the .NET Framework 4 and earlier versions, you have to use methods such as BeginRead and EndRead to implement asynchronous I/O operations. 这些方法在 .NET 中仍可用以支持旧版代码;但是,新的异步方法(如 ReadAsyncWriteAsyncCopyToAsyncFlushAsync)可帮助你更轻松地实现异步 i/o 操作。These methods are still available in .NET to support legacy code; however, the new async methods, such as ReadAsync, WriteAsync, CopyToAsync, and FlushAsync, help you implement asynchronous I/O operations more easily.

调用 EndRead 确定从流中读取的字节数。Call EndRead to determine how many bytes were read from the stream.

可以从 BeginRead对每个 IAsyncResult 调用一次 EndReadEndRead can be called once on every IAsyncResult from BeginRead.

此方法将一直阻塞,直到 I/O 操作已完成。This method blocks until the I/O operation has completed.