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);
[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.

如果作業在完成前取消, 則傳回的工作會包含Canceled Status屬性的值。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.

適用於

另請參閱