PipeStream.EndWrite(IAsyncResult) 方法


结束挂起的异步写入请求。Ends a pending asynchronous write request.

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



对挂起的异步请求的引用。The reference to the pending asynchronous 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.

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


对于每次调用 BeginWrite,都必须调用 EndWrite 一次。EndWrite must be called once for every call to BeginWrite. 这可以在调用 BeginWrite 的同一代码中完成,也可以在传递给 BeginWrite的回调中完成。This can be done either in the same code that called BeginWrite or in a callback that is passed to BeginWrite.

使用 CanWrite 属性来确定当前 PipeStream 对象是否支持写入操作。Use the CanWrite property to determine whether the current PipeStream object supports write operations.

如果关闭管道或将无效参数传递到 BeginWrite,则会立即引发相应的异常。If the pipe is closed or an invalid argument is passed to BeginWrite, the appropriate exceptions are raised immediately. 在执行请求的线程池线程上发生异步写入请求期间发生的错误。Errors that occur during an asynchronous write request occur on the thread pool thread that is performing the request. 当代码调用 EndWrite 方法时,将引发异常。The exceptions are raised when the code the calls EndWrite method.