BufferedStream.DisposeAsync 方法


以非同步方式釋放緩衝資料流所使用的非受控資源。Asynchronously releases the unmanaged resources used by the buffered stream.

 override System::Threading::Tasks::ValueTask DisposeAsync();
public override System.Threading.Tasks.ValueTask DisposeAsync ();
override this.DisposeAsync : unit -> System.Threading.Tasks.ValueTask
Public Overrides Function DisposeAsync () As ValueTask


代表非同步處署作業的工作。A task that represents the asynchronous dispose operation.


DisposeAsync 方法可讓您執行耗用大量資源的處置作業,而不會封鎖主執行緒。The DisposeAsync method enables you to perform a resource-intensive dispose operation without blocking the main thread. 這項效能考量對於 Windows 8.x 市集Windows 8.x Store 應用程式或 桌面desktop 應用程式而言特別重要,尤其是針對耗時的資料流作業可能會阻礙 UI 執行緒,使應用程式看起來像是停止運作的情況。This performance consideration is particularly important in a Windows 8.x 市集Windows 8.x Store app or 桌面desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. 非同步方法會與 Visual Basic 和C#中的 asyncawait 關鍵字搭配使用。The async methods are used in conjunction with the async and await keywords in Visual Basic and C#.

這個方法會將任何變更寫入至備份存放區,並關閉資料流程以釋放資源,藉此處置資料流程。This method disposes the stream by writing any changes to the backing store and closing the stream to release resources.

呼叫 DisposeAsync 可讓 BufferedStream 所使用的資源重新配置供其他用途之用。Calling DisposeAsync allows the resources used by the BufferedStream to be reallocated for other purposes. 如需詳細資訊,請參閱清除非受控資源For more information, see Cleaning Up Unmanaged Resources.