WaitHandle.Dispose 方法

定義

釋放 WaitHandle 類別目前的執行個體所使用的全部資源。Releases all resources used by the current instance of the WaitHandle class.

多載

Dispose()

釋放 WaitHandle 類別目前的執行個體所使用的全部資源。Releases all resources used by the current instance of the WaitHandle class.

Dispose(Boolean)

當在衍生類別中覆寫時,釋放 WaitHandle 所使用的 Unmanaged 資源,並選擇性釋放 Managed 資源。When overridden in a derived class, releases the unmanaged resources used by the WaitHandle, and optionally releases the managed resources.

Dispose()

釋放 WaitHandle 類別目前的執行個體所使用的全部資源。Releases all resources used by the current instance of the WaitHandle class.

public:
 virtual void Dispose();
public void Dispose ();
abstract member Dispose : unit -> unit
override this.Dispose : unit -> unit
Public Sub Dispose ()

實作

備註

這個方法相當於 Close 方法。This method is equivalent to the Close method.

注意

在您釋放 WaitHandle 的最後一個參考之前,請一律呼叫 CloseDispose()Always call Close or Dispose() before you release your last reference to the WaitHandle. 否則,將不會釋放它所使用的資源。Otherwise, the resources it is using will not be freed.

另請參閱

Dispose(Boolean)

當在衍生類別中覆寫時,釋放 WaitHandle 所使用的 Unmanaged 資源,並選擇性釋放 Managed 資源。When overridden in a derived class, releases the unmanaged resources used by the WaitHandle, and optionally releases the managed resources.

protected:
 virtual void Dispose(bool explicitDisposing);
protected virtual void Dispose (bool explicitDisposing);
abstract member Dispose : bool -> unit
override this.Dispose : bool -> unit
Protected Overridable Sub Dispose (explicitDisposing As Boolean)

參數

explicitDisposing
Boolean

true 表示釋放 Managed 和 Unmanaged 資源,false 則表示只釋放 Unmanaged 資源。true to release both managed and unmanaged resources; false to release only unmanaged resources.

備註

這個方法是由 Close 和 @no__t 1 方法所呼叫,並將 explicitDisposing 參數設定為 trueThis method is called by the Close and the Dispose() methods with the explicitDisposing parameter set to true. explicitDisposing 參數是 true 時,這個方法會釋放這個 @no__t 2 物件所參考之任何 managed 物件所持有的所有資源。When the explicitDisposing parameter is true, this method releases all resources held by any managed objects that this WaitHandle object references.

給繼承者的注意事項

您應該覆寫 Dispose(Boolean) 方法,以釋放衍生類別中所配置的資源。You should override the Dispose(Boolean) method to release resources allocated in derived classes.

@No__t-0 或 @no__t 1 方法可由其他物件多次呼叫。The Close() or Dispose() method can be called multiple times by other objects. 覆寫這個方法時,請小心不要參考先前已在 DisposeClose 的呼叫中處置的物件。When overriding this method, be careful not to reference objects that have been previously disposed in an earlier call to Dispose or Close.

另請參閱

適用於