Compartir a través de


Método SafeHandle.Dispose ()

 

Publicado: octubre de 2016

Libera todos los recursos que usa la clase SafeHandle.

Espacio de nombres:   System.Runtime.InteropServices
Ensamblado:  mscorlib (en mscorlib.dll)

Sintaxis

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

Implementa

IDisposable.Dispose()

Comentarios

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.

Nota

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.

Seguridad

SecurityPermission

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

Información de versión

Plataforma universal de Windows
Disponible desde 8
.NET Framework
Disponible desde 2.0
Biblioteca de clases portable
Se admite en: plataformas portátiles de .NET
Silverlight
Disponible desde 2.0
Windows Phone Silverlight
Disponible desde 7.0
Windows Phone
Disponible desde 8.1

Ver también

Dispose Sobrecarga
Clase SafeHandle
Espacio de nombres System.Runtime.InteropServices

Volver al principio