Freigeben über


SafeHandle.DangerousAddRef-Methode: (Boolean)

 

Veröffentlicht: Oktober 2016

Inkrementiert manuell den Verweiszähler für SafeHandle-Instanzen.

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

Syntax

[SecurityCriticalAttribute]
public void DangerousAddRef(
    ref bool success
)
public:
[SecurityCriticalAttribute]
void DangerousAddRef(
    bool% success
)
[<SecurityCriticalAttribute>]
member DangerousAddRef : 
        success:bool byref -> unit
<SecurityCriticalAttribute>
Public Sub DangerousAddRef (
    ByRef success As Boolean
)

Parameter

  • success
    Type: System.Boolean

    true, wenn der Verweiszähler erfolgreich inkrementiert wurde, andernfalls false.

Hinweise

The M:System.Runtime.InteropServices.SafeHandle.DangerousAddRef(System.Boolean@) method prevents the common language runtime from reclaiming memory used by a handle (which occurs when the runtime calls the M:System.Runtime.InteropServices.SafeHandle.ReleaseHandle method). You can use this method to manually increment the reference count on a T:System.Runtime.InteropServices.SafeHandle instance. M:System.Runtime.InteropServices.SafeHandle.DangerousAddRef(System.Boolean@) returns a Boolean value using a ref parameter (success) that indicates whether the reference count was incremented successfully. This allows your program logic to back out in case of failure. You should set success to false before calling M:System.Runtime.InteropServices.SafeHandle.DangerousAddRef(System.Boolean@). If success is true, avoid resource leaks by matching the call to M:System.Runtime.InteropServices.SafeHandle.DangerousAddRef(System.Boolean@) with a corresponding call to M:System.Runtime.InteropServices.SafeHandle.DangerousRelease.

Achtung

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.

Sicherheit

SecurityPermission

for permission to call unmanaged code. Security action: F:System.Security.Permissions.SecurityAction.LinkDemand. Associated enumeration: F:System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode

Versionsinformationen

Universelle Windows-Plattform
Verfügbar seit 8
.NET Framework
Verfügbar seit 2.0
Portierbare Klassenbibliothek
Unterstützt in: portierbare .NET-Plattformen
Silverlight
Verfügbar seit 2.0
Windows Phone Silverlight
Verfügbar seit 7.0
Windows Phone
Verfügbar seit 8.1

Siehe auch

DangerousRelease
SafeHandle-Klasse
System.Runtime.InteropServices-Namespace

Zurück zum Anfang