WindowsImpersonationContext.Dispose WindowsImpersonationContext.Dispose WindowsImpersonationContext.Dispose WindowsImpersonationContext.Dispose Method

定義

釋放 WindowsImpersonationContext 所使用的所有資源。Releases all resources used by the WindowsImpersonationContext.

多載

Dispose() Dispose() Dispose() Dispose()

釋放 WindowsImpersonationContext 所使用的所有資源。Releases all resources used by the WindowsImpersonationContext.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

釋放 WindowsImpersonationContext 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources used by the WindowsImpersonationContext and optionally releases the managed resources.

Dispose() Dispose() Dispose() Dispose()

釋放 WindowsImpersonationContext 所使用的所有資源。Releases all resources used by the WindowsImpersonationContext.

public:
 virtual void Dispose();
[System.Runtime.InteropServices.ComVisible(false)]
public void Dispose ();
abstract member Dispose : unit -> unit
override this.Dispose : unit -> unit
Public Sub Dispose ()

實作

備註

Dispose 使用完畢時,請呼叫 WindowsImpersonationContextCall Dispose when you are finished using the WindowsImpersonationContext. Dispose 方法會將 WindowsImpersonationContext 保留在無法使用的狀態。The Dispose method leaves the WindowsImpersonationContext in an unusable state. 之後呼叫Dispose,您必須釋放所有的參考WindowsImpersonationContext讓記憶體回收行程可以回收記憶體,WindowsImpersonationContext所佔用。After calling Dispose, you must release all references to the WindowsImpersonationContext so the garbage collector can reclaim the memory that the WindowsImpersonationContext was occupying. 如需詳細資訊,請參閱 < 清除 Unmanaged 資源向上實作 Dispose 方法For more information, see Cleaning Up Unmanaged Resources and Implementing a Dispose Method.

注意

在您釋放最後一個 Dispose 參考之前,請務必呼叫 WindowsImpersonationContextAlways call Dispose before you release your last reference to the WindowsImpersonationContext. 否則工作窗格所使用的資源不會釋放,直到記憶體回收行程呼叫 WindowsImpersonationContext 物件的 Finalize 方法。Otherwise, the resources it is using will not be freed until the garbage collector calls the WindowsImpersonationContext object's Finalize method.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

釋放 WindowsImpersonationContext 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources used by the WindowsImpersonationContext and optionally releases the managed resources.

protected:
 virtual void Dispose(bool disposing);
[System.Runtime.InteropServices.ComVisible(false)]
protected virtual void Dispose (bool disposing);
abstract member Dispose : bool -> unit
override this.Dispose : bool -> unit
Protected Overridable Sub Dispose (disposing As Boolean)

參數

disposing
Boolean Boolean Boolean Boolean

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

備註

這個方法會呼叫公用Dispose()方法和Finalize方法。This method is called by the public Dispose() method and the Finalize method. Dispose() 叫用受保護Dispose(Boolean)方法disposing參數設為trueDispose() invokes the protected Dispose(Boolean) method with the disposing parameter set to true. Finalize 叫用Dispose具有disposing設定為falseFinalize invokes Dispose with disposing set to false.

disposing參數為 true 時,這個方法由任何 managed 物件持有的資源全部釋出這個WindowsImpersonationContext參考。When the disposing parameter is true, this method releases all resources held by any managed objects that this WindowsImpersonationContext references. 這個方法會叫用每個參考物件的 Dispose() 方法。This method invokes the Dispose() method of each referenced object.

給繼承者的注意事項

Dispose 可以被其他物件呼叫多次。 Dispose can be called multiple times by other objects. 當覆寫Dispose(Boolean)小心不要參考先前處置好的呼叫中的物件DisposeWhen overriding Dispose(Boolean) be careful not to reference objects that have been previously disposed of in an earlier call to Dispose. 如需有關如何實作Dispose(Boolean),請參閱 <<c2> 實作 Dispose 方法For more information about how to implement Dispose(Boolean), see Implementing a Dispose Method.

如需詳細資訊DisposeFinalize(),請參閱清除 Unmanaged 資源總For more information about Dispose and Finalize(), see Cleaning Up Unmanaged Resources.

適用於