SafeHandle.DangerousRelease Method ()

 

Manually decrements the reference counter on a SafeHandle instance.

Namespace:   System.Runtime.InteropServices
Assembly:  mscorlib (in mscorlib.dll)

[SecurityCriticalAttribute]
public void DangerousRelease()

The DangerousRelease method is the counterpart to DangerousAddRef. You should always match a call to the DangerousRelease method with a successful call to DangerousAddRef.

System_CAPS_cautionCaution

This method is intended for advanced users and must always be used carefully. To avoid leaking handle resources, always call this method inside a constrained execution region (CER), where a thread abort cannot interrupt processing. 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. Do not expose DangerousAddRef or DangerousRelease calls to untrusted code.

SecurityPermission

for permission to call unmanaged code. Security action: LinkDemand. Associated enumeration: SecurityPermissionFlag.UnmanagedCode

Universal Windows Platform
Available since 8
.NET Framework
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: