SearchResultCollection.Dispose 方法

定義

釋放 SearchResultCollection 物件所使用的全部資源。Releases all resources that are used by the SearchResultCollection object.

多載

Dispose()

釋放 SearchResultCollection 物件所使用的全部資源。Releases all resources that are used by the SearchResultCollection object.

Dispose(Boolean)

釋放 SearchResultCollection 物件所使用的 Unmanaged 資源,並選擇性釋放 Managed 資源。Releases the unmanaged resources that are used by the SearchResultCollection object and optionally releases the managed resources.

Dispose()

釋放 SearchResultCollection 物件所使用的全部資源。Releases all resources that are used by the SearchResultCollection object.

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

實作

備註

方法, 可讓所使用的資源重新配置供其他用途之用SearchResultCollectionDisposeThe Dispose method, it allows the resources that are used by the SearchResultCollection to be reallocated for other purposes. 如需的詳細Dispose資訊, 請參閱清除非受控資源For more information about Dispose, see Cleaning Up Unmanaged Resources.

垃圾收集行程不會釋放SearchResultCollection物件的記憶體。The garbage collector does not release memory for a SearchResultCollection object. 因此, 應用程式必須明確呼叫Dispose方法, 以防止記憶體流失。Therefore, an application must call the Dispose method explicitly to prevent a memory leak.

Dispose(Boolean)

釋放 SearchResultCollection 物件所使用的 Unmanaged 資源,並選擇性釋放 Managed 資源。Releases the unmanaged resources that are used by the SearchResultCollection object and optionally releases the managed resources.

protected:
 virtual void Dispose(bool disposing);
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

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. FinalizeDispose falsedisposing , 並將參數設為。Finalize invokes Dispose with the disposing parameter set to false.

當參數為true時, 這個方法會釋放此SearchResultCollection參考之任何 managed 物件所持有的所有資源。 disposingWhen the disposing parameter is true, this method releases all resources that are held by any managed objects that this SearchResultCollection references.

垃圾收集行程不會釋放SearchResultCollection物件的記憶體。The garbage collector does not release memory for a SearchResultCollection object. 因此, 您必須明確呼叫Dispose方法, 以避免記憶體流失。Therefore, you must call the Dispose method explicitly to prevent a memory leak.

這個方法Dispose會叫用集合中每個物件的方法。This method invokes the Dispose method of each object in the collection.

如需Dispose()Finalize的詳細資訊, 請參閱清除非受控資源和覆寫 Finalize 方法For more information about Dispose() and Finalize, see Cleaning Up Unmanaged Resources and Overriding the Finalize Method.

給繼承者的注意事項

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

適用於