DisposableObject.Dispose 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| Dispose() |
釋放此物件所使用的所有資源。 |
| Dispose(Boolean) |
釋放此物件所使用的資源。 |
Dispose(Boolean)
釋放此物件所使用的資源。
protected virtual void Dispose(bool disposing);
abstract member Dispose : bool -> unit
override this.Dispose : bool -> unit
參數
- disposing
- Boolean
若設為 true,則直接呼叫該方法,並處置管理與非管理資源。 若設為 false,則垃圾回收終端器會呼叫該方法,且僅釋放未管理的資源。
備註
此方法同時 Dispose() 由方法與物件終結器呼叫。 當方法呼叫 Dispose() 時, disposing 參數會被設定為 true。 當物件終結器在終結器執行緒中呼叫時, disposing 參數會被設定為 false。
子類別應該覆寫這個方法,釋放他們持有的資源,然後呼叫基礎實作。