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. 非同步方法會與 Visual Basic 和async C#中的和await關鍵字搭配使用。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. 如需詳細資訊, 請參閱清除非受控資源For more information, see Cleaning Up Unmanaged Resources.

適用於