SafeHandle.DangerousRelease 方法


手動遞減 SafeHandle 執行個體上的參考計數器。Manually decrements the reference counter on a SafeHandle instance.

 void DangerousRelease();
public void DangerousRelease ();
public void DangerousRelease ();
member this.DangerousRelease : unit -> unit
member this.DangerousRelease : unit -> unit
Public Sub DangerousRelease ()


DangerousRelease方法是的對應方法 DangerousAddRefThe DangerousRelease method is the counterpart to DangerousAddRef. 您應該一律符合呼叫方法的呼叫, DangerousRelease 並成功呼叫 DangerousAddRefYou should always match a call to the DangerousRelease method with a successful call to DangerousAddRef.


這個方法適用于 advanced 使用者,必須一律謹慎使用。This method is intended for advanced users and must always be used carefully. 為了避免流失控制碼資源,請一律在受限制的執列區域內呼叫這個方法 (CER) ,其中線程中止無法中斷處理。To avoid leaking handle resources, always call this method inside a constrained execution region (CER), where a thread abort cannot interrupt processing. 與不相符的 DangerousAddRef 呼叫可能會造成資源流失的相同方式,不相符的 DangerousRelease 呼叫可能會導致其他執行緒看不到不正確控制碼狀態。In the same way that unmatched DangerousAddRef calls can cause resource leaks, unmatched DangerousRelease calls can cause invalid handle states to become visible to other threads. 請勿公開 DangerousAddRefDangerousRelease 呼叫不受信任的程式碼。Do not expose DangerousAddRef or DangerousRelease calls to untrusted code.