DeflateStream.EndWrite(IAsyncResult) 方法


结束异步写操作。Ends an asynchronous write operation. (请考虑改用 WriteAsync(Byte[], Int32, Int32) 方法。)(Consider using the WriteAsync(Byte[], Int32, Int32) method instead.)

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



对未完成的异步 I/O 请求的引用。A reference to the outstanding asynchronous I/O request.


asyncResultnullasyncResult is null.

asyncResult 不源于当前流的 BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) 方法。asyncResult did not originate from a BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) method on the current stream.

在调用 WaitOne() 期间引发了异常。An exception was thrown during a call to WaitOne().

此流为 nullThe stream is null.


结束写入调用无效。The end write call is invalid.


.NET Framework 4.5.NET Framework 4.5开始,可以通过使用 WriteAsync 方法执行异步写入操作。Starting with the .NET Framework 4.5.NET Framework 4.5, you can perform asynchronous write operations by using the WriteAsync method. EndWrite 方法仍在 .NET Framework 4.5.NET Framework 4.5 中可用以支持旧版代码;不过,您可以使用新的异步方法更轻松地实现异步 i/o 操作。The EndWrite method is still available in the .NET Framework 4.5.NET Framework 4.5 to support legacy code; however, you can implement asynchronous I/O operations more easily by using the new async methods. 有关详细信息,请参阅异步文件 I/OFor more information, see Asynchronous File I/O.

对于每次调用 BeginWrite 方法,只需调用一次 EndWriteEndWrite must be called only once for every call to the BeginWrite method.

此方法将一直阻塞,直到 I/O 操作已完成。This method blocks until the I/O operation has completed. 在异步写入请求期间发生的错误(例如,i/o 请求过程中的磁盘故障)将在线程池线程上发生,并在调用 EndWrite时变为可见。Errors 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. 调用 EndWrite时,线程池线程引发的异常将不可见。Exceptions thrown by the thread pool thread will not be visible when calling EndWrite.