CryptoStream.EndWrite(IAsyncResult) 方法

定义

结束执行异步写入操作。Ends an asynchronous write operation. (请考虑改用 WriteAsync。)(Consider using WriteAsync 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

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

异常

asyncResultnullasyncResult is null.

处于挂起状态的写入操作的句柄不可用。A handle to the pending write operation is not available.

- 或 --or-

挂起操作不支持写入。The pending operation does not support writing.

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.

注解

在 .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 中仍可用以支持旧版代码;但是,新的异步方法(如 ReadAsyncWriteAsyncCopyToAsyncFlushAsync)可帮助你更轻松地实现异步 i/o 操作。These methods are still available in .NET 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.

必须对 BeginWrite每个 IAsyncResult 只调用一次 EndWriteEndWrite must be called exactly once on every IAsyncResult from BeginWrite.

此方法将一直阻塞,直到 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.

适用于