Compartir a través de


Método SafeHandle.Close ()

 

Publicado: octubre de 2016

Marca el identificador para soltar y liberar recursos.

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

Sintaxis

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

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 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.

Nota

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.

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

.NET Framework
Disponible desde 2.0
Silverlight
Disponible desde 2.0
Windows Phone Silverlight
Disponible desde 7.0

Ver también

Clase SafeHandle
Espacio de nombres System.Runtime.InteropServices

Volver al principio