BlockingCollection<T>.Dispose 方法

定義

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

多載

Dispose()

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

Dispose(Boolean)

釋放 BlockingCollection<T> 執行個體所使用的資源。Releases resources used by the BlockingCollection<T> instance.

Dispose()

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

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

實作

備註

Dispose 方法不是安全線程。The Dispose method is not thread-safe.

Dispose 使用完畢時,請呼叫 BlockingCollection<T>Call Dispose when you are finished using the BlockingCollection<T>. Dispose 方法會將 BlockingCollection<T> 保留在無法使用的狀態。The Dispose method leaves the BlockingCollection<T> in an unusable state. 呼叫 Dispose之後,您必須釋放所有對 BlockingCollection<T> 的參考,讓垃圾收集行程可以回收 BlockingCollection<T> 所佔用的記憶體。After calling Dispose, you must release all references to the BlockingCollection<T> so the garbage collector can reclaim the memory that the BlockingCollection<T> was occupying.

如需詳細資訊,請參閱清除非受控資源執行 Dispose 方法For more information, see Cleaning Up Unmanaged Resources and Implementing a Dispose Method.

注意

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

另請參閱

Dispose(Boolean)

釋放 BlockingCollection<T> 執行個體所使用的資源。Releases resources used by the BlockingCollection<T> instance.

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),或是最後送至完成項 (false)。Whether being disposed explicitly (true) or due to a finalizer (false).

另請參閱

適用於