Freigeben über


SafeHandle.Close-Methode: ()

 

Veröffentlicht: Oktober 2016

Markiert das Handle für das Freigeben und Verfügbarmachen von Ressourcen.

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

Syntax

[SecurityCriticalAttribute]
public void Close()
public:
[SecurityCriticalAttribute]
void Close()
[<SecurityCriticalAttribute>]
member Close : unit -> unit
<SecurityCriticalAttribute>
Public Sub Close

Hinweise

Calling the M:System.Runtime.InteropServices.SafeHandle.Close or M:System.Runtime.InteropServices.SafeHandle.Dispose method allows the resources to be freed. This might not happen immediately if other threads are using the same safe handle object, but will happen as soon as that is no longer the case. Although most classes that use the T:System.Runtime.InteropServices.SafeHandle class do not need to provide a finalizer, this is sometimes necessary (for example, to flush out file buffers or to write some data back into memory). In this case, the class can provide a finalizer that is guaranteed to run before the T:System.Runtime.InteropServices.SafeHandle critical finalizer runs.

Call the M:System.Runtime.InteropServices.SafeHandle.Close or M:System.Runtime.InteropServices.SafeHandle.Dispose method when you are finished using the T:System.Runtime.InteropServices.SafeHandle object.

Hinweis

Always call M:System.Runtime.InteropServices.SafeHandle.Close or M:System.Runtime.InteropServices.SafeHandle.Dispose before you release your last reference to the T:System.Runtime.InteropServices.SafeHandle object. Otherwise, the resources it is using will not be freed until the garbage collector calls the T:System.Runtime.InteropServices.SafeHandle object's M:System.Runtime.InteropServices.SafeHandle.Finalize method.

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

.NET Framework
Verfügbar seit 2.0
Silverlight
Verfügbar seit 2.0
Windows Phone Silverlight
Verfügbar seit 7.0

Siehe auch

SafeHandle-Klasse
System.Runtime.InteropServices-Namespace

Zurück zum Anfang