DirectoryEntry.Dispose(Boolean) DirectoryEntry.Dispose(Boolean) DirectoryEntry.Dispose(Boolean) DirectoryEntry.Dispose(Boolean) Method

定義

處置 DirectoryEntry 所使用的資源 (除了記憶體之外)。Disposes of the resources (other than memory) that are used by the DirectoryEntry.

protected:
 override void Dispose(bool disposing);
protected override void Dispose (bool disposing);
override this.Dispose : bool -> unit
Protected Overrides 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. DisposeDispose 用受true保護的方法, 並將參數設定為。disposingDispose invokes the protected Dispose method with the disposing parameter set to true. Finalize使用設定disposingfalse的叫用。 DisposeFinalize invokes Dispose with disposing set to false.

當參數為true時,這個方法會釋放此DirectoryEntry物件所參考之任何 managed 物件所持有的所有資源。 disposingWhen the disposing parameter is true, this method releases all resources that are held by any managed objects that this DirectoryEntry object references. 這個方法會叫用每個參考物件的 Dispose 方法。This method invokes the Dispose method of each referenced object.

如需DisposeFinalize方法的詳細資訊,請參閱覆寫 Finalize 方法For more information about the Dispose and Finalize methods, see Overriding the Finalize Method.

給繼承者的注意事項

Dispose() 可以被其他物件呼叫多次。 Dispose() can be called multiple times by other objects. 覆寫 Dispose(Boolean) 時,請小心不要參考到先前已在對 Dispose() 的早期呼叫中被處置 (Dispose) 的物件。When overriding Dispose(Boolean), be careful not to reference objects that have been previously disposed of in an earlier call to Dispose(). 如需如何執行Dispose()的詳細資訊, 請參閱[執行 Dispose 方法](~/docs/standard/garbage-collection/implementing-dispose.md)。For more information about how to implement Dispose(), see [Implementing a Dispose Method](~/docs/standard/garbage-collection/implementing-dispose.md).

適用於

另請參閱