Freigeben über


SafeHandle.Dispose-Methode: ()

 

Veröffentlicht: Oktober 2016

Gibt alle von der SafeHandle-Klasse verwendeten Ressourcen frei.

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

Syntax

public void Dispose()
public:
virtual void Dispose() sealed
abstract Dispose : unit -> unit
override Dispose : unit -> unit
Public Sub Dispose

Implementiert

IDisposable.Dispose()

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 instance of the safe handle, but will happen as soon as that is no longer the case. Although most classes using T:System.Runtime.InteropServices.SafeHandle 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, they 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. The M:System.Runtime.InteropServices.SafeHandle.Close method leaves the T:System.Runtime.InteropServices.SafeHandle object in an unusable state.

Hinweis

Always call the M:System.Runtime.InteropServices.SafeHandle.Close or M:System.Runtime.InteropServices.SafeHandle.Dispose method 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

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

Dispose Überladen
SafeHandle-Klasse
System.Runtime.InteropServices-Namespace

Zurück zum Anfang