BufferedStream.EndRead(IAsyncResult) 方法


等候暫止的非同步讀取作業完成。Waits for the pending asynchronous read operation to complete. (請考慮用 ReadAsync(Byte[], Int32, Int32, CancellationToken) 替代。)(Consider using ReadAsync(Byte[], Int32, Int32, CancellationToken) 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 wait for.


從資料流讀取的位元組數,位於 0 (零) 和您所要求的位元組數之間。The number of bytes read from the stream, between 0 (zero) and the number of bytes you requested. 僅在資料流末端,資料流只傳回 0,否則,他們應該停止直到至少有 1 位元組可用。Streams only return 0 only at the end of the stream, otherwise, they should block until at least 1 byte is available.


asyncResultnullasyncResult is null.

這個 IAsyncResult 物件不是透過對這個類別呼叫 BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) 所建立。This IAsyncResult object was not created by calling BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) on this class.


在 .NET Framework 4 和舊版中,您必須使用 BeginReadEndRead 等方法來執行非同步檔案作業。In the .NET Framework 4 and earlier versions, you have to use methods such as BeginRead and EndRead to implement asynchronous file operations. 這些方法仍可在 .NET Framework 4.5.NET Framework 4.5 中使用,以支援舊版程式碼;不過,新的非同步方法(例如 ReadAsyncWriteAsyncFlushAsync)可協助您更輕鬆地執行非同步檔案作業。These methods are still available in the .NET Framework 4.5.NET Framework 4.5 to support legacy code; however, the new async methods, such as ReadAsync, WriteAsync, and FlushAsync, help you implement asynchronous file operations more easily.

必須使用此 IAsyncResult 呼叫 EndRead,以找出已讀取的位元組數目。EndRead must be called with this IAsyncResult to find out how many bytes were read.