SafeHandle.DangerousRelease SafeHandle.DangerousRelease SafeHandle.DangerousRelease SafeHandle.DangerousRelease Method

定义

手动递减 SafeHandle 实例中的引用计数器。Manually decrements the reference counter on a SafeHandle instance.

public:
 void DangerousRelease();
[System.Security.SecurityCritical]
public void DangerousRelease ();
member this.DangerousRelease : unit -> unit
Public Sub DangerousRelease ()

注解

方法是与DangerousAddRef对应的。 DangerousReleaseThe DangerousRelease method is the counterpart to DangerousAddRef. 应始终将对方法的调用与DangerousRelease对的调用成功DangerousAddRef进行匹配。You should always match a call to the DangerousRelease method with a successful call to DangerousAddRef.

注意

此方法适用于高级用户,必须始终谨慎使用。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.

安全性

SecurityPermission
用于调用非托管代码的权限。for permission to call unmanaged code. 安全操作: LinkDemandSecurity action: LinkDemand. 关联的枚举:UnmanagedCodeAssociated enumeration: UnmanagedCode

适用于

另请参阅