Stream.EndWrite(IAsyncResult) Stream.EndWrite(IAsyncResult) Stream.EndWrite(IAsyncResult) Stream.EndWrite(IAsyncResult) Method

定義

結束非同步的寫入作業。Ends an asynchronous write operation. (請考慮用 WriteAsync(Byte[], Int32, Int32) 替代。)(Consider using WriteAsync(Byte[], Int32, Int32) instead.)

public:
 virtual void EndWrite(IAsyncResult ^ asyncResult);
public virtual void EndWrite (IAsyncResult asyncResult);
abstract member EndWrite : IAsyncResult -> unit
override this.EndWrite : IAsyncResult -> unit
Public Overridable Sub EndWrite (asyncResult As IAsyncResult)

參數

asyncResult
IAsyncResult IAsyncResult IAsyncResult IAsyncResult

未處理的非同步 I/O 要求的參考。A reference to the outstanding asynchronous I/O request.

例外狀況

暫止寫入作業的控制代碼無法使用。A handle to the pending write operation is not available.

-或--or-

暫止的作業不支援寫入。The pending operation does not support writing.

資料流已關閉或發生內部錯誤。The stream is closed or an internal error has occurred.

備註

在 .NET Framework 4 (含) 以前版本中,您必須使用方法 (例如 BeginWriteEndWrite ) 實作非同步 I/O 作業。In the .NET Framework 4 and earlier versions, you have to use methods such as BeginWrite and EndWrite to implement asynchronous I/O operations. 這些方法是中仍然可用.NET Framework 4.5.NET Framework 4.5以支援舊版的程式碼; 不過,新的非同步方法,例如ReadAsyncWriteAsyncCopyToAsync,和FlushAsync,協助您更輕鬆地實作非同步 I/O 作業。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, CopyToAsync, and FlushAsync, help you implement asynchronous I/O operations more easily.

EndWrite 必須正好一次上呼叫每個IAsyncResultBeginWriteEndWrite must be called exactly once on every IAsyncResult from BeginWrite.

這個方法會封鎖,直到 I/O 作業完成為止。This method blocks until the I/O operation has completed. 非同步寫入要求,例如磁碟失敗期間,在 I/O 要求期間發生的錯誤在執行緒集區執行緒上發生,並呼叫時變成可見EndWriteErrors that occur during an asynchronous write request, such as a disk failure during the I/O request, occur on the thread pool thread and become visible upon a call to EndWrite. 執行緒集區執行緒擲回例外狀況時呼叫,將無法看到EndWriteExceptions thrown by the thread pool thread will not be visible when calling EndWrite.

適用於

另請參閱