MemoryStream.FlushAsync(CancellationToken) 方法

定义

异步清除此流的所有缓冲区,并监视取消请求。Asynchronously clears all buffers for this stream, 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);
[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

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

返回

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

属性

异常

已释放流。The stream has been disposed.

注解

由于写入到 MemoryStream 对象的任何数据都写入到 RAM 中,因此此方法是多余的。Because any data written to a MemoryStream object is written into RAM, this method is redundant.

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

可以通过创建 CancellationTokenSource 类的实例并将 Token 属性作为 cancellationToken 参数传递来创建取消标记。You can create a cancellation token by creating an instance of the CancellationTokenSource class and passing the Token property as the cancellationToken parameter.

适用于

另请参阅