FileStream.FlushAsync(CancellationToken) FileStream.FlushAsync(CancellationToken) FileStream.FlushAsync(CancellationToken) Method

定义

异步清理这个流的所有缓冲区,并使所有缓冲数据写入基础设备,并且监控取消请求。Asynchronously clears all buffers for this stream, 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);
[System.Runtime.InteropServices.ComVisible(false)]
public override System.Threading.Tasks.Task FlushAsync (System.Threading.CancellationToken cancellationToken);
override this.FlushAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task

参数

cancellationToken
CancellationToken CancellationToken CancellationToken

要监视取消请求的标记。The token to monitor for cancellation requests.

返回

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

异常

已释放流。The stream has been disposed.

注解

如果在操作完成前取消该操作, 则返回的任务包含Canceled Status属性的值。If the operation is canceled before it completes, the returned task contains the Canceled value for the Status property. 如果释放了文件的句柄, 则返回的任务将ObjectDisposedException Exception在属性中包含异常。If the handle to the file is disposed, the returned task contains the ObjectDisposedException exception in the Exception property.

适用于

另请参阅