CriticalHandle.Dispose-Methode: ()
Veröffentlicht: Oktober 2016
Gibt alle vom CriticalHandle 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
Hinweise
Calling the M:System.Runtime.InteropServices.CriticalHandle.Close or M:System.Runtime.InteropServices.CriticalHandle.Dispose method allows the resources to be freed. Unlike the T:System.Runtime.InteropServices.SafeHandle class, this will always happen immediately since there is no reference count to indicate that other threads are using this handle. Therefore, you must employ a synchronization mechanism to ensure it is safe to call the M:System.Runtime.InteropServices.CriticalHandle.Dispose method. Although most classes that use the T:System.Runtime.InteropServices.CriticalHandle 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.CriticalHandle critical finalizer runs.
Call the M:System.Runtime.InteropServices.CriticalHandle.Close or M:System.Runtime.InteropServices.CriticalHandle.Dispose method when you are finished using the T:System.Runtime.InteropServices.CriticalHandle object. The M:System.Runtime.InteropServices.CriticalHandle.Close method leaves the T:System.Runtime.InteropServices.CriticalHandle object in an unusable state.
Note Always call the Close or Dispose method before you release your last reference to the CriticalHandle object. Otherwise, the resources it is using will not be freed until the garbage collector calls the CriticalHandle object's Finalize method.
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 8.0
Windows Phone
Verfügbar seit 8.1
Siehe auch
Dispose Überladen
CriticalHandle-Klasse
System.Runtime.InteropServices-Namespace
Zurück zum Anfang