ReaderWriterLockSlim.Dispose 方法

定義

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

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

實作

例外狀況

WaitingReadCount 大於零。WaitingReadCount is greater than zero.

-或--or- WaitingUpgradeCount 大於零。WaitingUpgradeCount is greater than zero.

-或--or- WaitingWriteCount 大於零。WaitingWriteCount is greater than zero.

備註

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

注意

在您Dispose釋放物件的ReaderWriterLockSlim最後一個參考之前, 請一律呼叫。Always call Dispose before you release your last reference to the ReaderWriterLockSlim object.

適用於