CryptoStream.FlushAsync(CancellationToken) 方法

定义

异步清理当前流的所有缓冲区,并使所有缓冲数据写入基础设备,并且监控取消请求。Clears all buffers for the current stream asynchronously, causes any buffered data to be written to the underlying device, and monitors cancellation requests.

public:
 override System::Threading::Tasks::Task ^ FlushAsync(System::Threading::CancellationToken cancellationToken);
public override System.Threading.Tasks.Task FlushAsync (System.Threading.CancellationToken cancellationToken);
override this.FlushAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task

参数

cancellationToken
CancellationToken

要监视的取消请求标记。The token to monitor for cancellation requests. 默认值为 NoneThe default value is None.

返回

表示异步刷新操作的任务。A task that represents the asynchronous flush operation.

异常

已释放流。The stream has been disposed.

注解

必须先将对的调用 FlushAsyncawait (C#)或 Await (Visual Basic)运算符,才能暂停执行方法,直到任务完成。You must preface your call to FlushAsync with the await (C#) or Await (Visual Basic) operator to suspend execution of the method until the task is complete. 有关详细信息,请参阅使用 Async 和 Await 的异步编程For more information, see Asynchronous Programming with Async and Await.

如果在操作完成前取消该操作,则返回的任务将包含 Status 属性的 Canceled 值。If the operation is canceled before it completes, the returned task contains the Canceled value for the Status property.

适用于