BufferedStream.EndWrite(IAsyncResult) 方法

定義

結束非同步寫入作業並封鎖,直到 I/O 作業完成。Ends an asynchronous write operation and blocks until the I/O operation is complete. (請考慮用 WriteAsync(Byte[], Int32, Int32, CancellationToken) 替代。)(Consider using WriteAsync(Byte[], Int32, Int32, CancellationToken) instead.)

public:
 override void EndWrite(IAsyncResult ^ asyncResult);
public override void EndWrite (IAsyncResult asyncResult);
override this.EndWrite : IAsyncResult -> unit
Public Overrides Sub EndWrite (asyncResult As IAsyncResult)

參數

asyncResult
IAsyncResult

暫止的非同步要求。The pending asynchronous request.

例外狀況

asyncResultnullasyncResult is null.

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

備註

在 .NET Framework 4 和舊版中,您必須使用 BeginWriteEndWrite 等方法來執行非同步檔案作業。In the .NET Framework 4 and earlier versions, you have to use methods such as BeginWrite and EndWrite 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.

每次呼叫 BeginRead時,都必須只呼叫一次 EndWriteEndWrite must be called exactly once for every call to BeginRead. 開始另一個讀取作業之前無法結束讀取程式,可能會導致鎖死或其他不想要的行為。Failing to end a read process before beginning another read operation can cause deadlock or other undesirable behavior.

適用於