Stream.DisposeAsync Stream.DisposeAsync Stream.DisposeAsync Stream.DisposeAsync Method

定義

以非同步方式釋放 Stream 使用的不受控資源。Asynchronously releases the unmanaged resources used by the Stream.

public:
 virtual System::Threading::Tasks::ValueTask DisposeAsync();
public virtual System.Threading.Tasks.ValueTask DisposeAsync ();
abstract member DisposeAsync : unit -> System.Threading.Tasks.ValueTask
override this.DisposeAsync : unit -> System.Threading.Tasks.ValueTask
Public Overridable 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. 非同步方法會用於搭配asyncawaitVisual Basic 和 C# 中的關鍵字。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可讓所使用的資源Stream重新配置用於其他用途。Calling DisposeAsync allows the resources used by the Stream to be reallocated for other purposes. 如需詳細資訊,請參閱 < 清除 Unmanaged 資源總For more information, see Cleaning Up Unmanaged Resources.

適用於