Clase CriticalHandle
Publicado: octubre de 2016
Representa una clase contenedora para los recursos de controlador.
Espacio de nombres: System.Runtime.InteropServices
Ensamblado: mscorlib (en mscorlib.dll)
Jerarquía de herencia
System.Object
System.Runtime.ConstrainedExecution.CriticalFinalizerObject
System.Runtime.InteropServices.CriticalHandle
Microsoft.Win32.SafeHandles.CriticalHandleMinusOneIsInvalid
Microsoft.Win32.SafeHandles.CriticalHandleZeroOrMinusOneIsInvalid
Sintaxis
[SecurityCriticalAttribute]
[SecurityPermissionAttribute(SecurityAction.InheritanceDemand,
UnmanagedCode = true)]
public abstract class CriticalHandle : CriticalFinalizerObject,
IDisposable
[SecurityCriticalAttribute]
[SecurityPermissionAttribute(SecurityAction::InheritanceDemand,
UnmanagedCode = true)]
public ref class CriticalHandle abstract : CriticalFinalizerObject,
IDisposable
[<AbstractClass>]
[<SecurityCriticalAttribute>]
[<SecurityPermissionAttribute(SecurityAction.InheritanceDemand,
UnmanagedCode = true)>]
type CriticalHandle =
class
inherit CriticalFinalizerObject
interface IDisposable
end
<SecurityCriticalAttribute>
<SecurityPermissionAttribute(SecurityAction.InheritanceDemand,
UnmanagedCode := True)>
Public MustInherit Class CriticalHandle
Inherits CriticalFinalizerObject
Implements IDisposable
Constructores
Nombre | Descripción | |
---|---|---|
![]() |
CriticalHandle(IntPtr) | Inicializa una nueva instancia de la clase CriticalHandle con un valor de identificador no válido especificado. |
Propiedades
Nombre | Descripción | |
---|---|---|
![]() |
IsClosed | Obtiene un valor que indica si el identificador está cerrado. |
![]() |
IsInvalid | Cuando se invalida en una clase derivada, obtiene un valor que indica si este identificador es no válido. |
Métodos
Nombre | Descripción | |
---|---|---|
![]() |
Close() | Marca el identificador para soltar y liberar recursos. |
![]() |
Dispose() | Libera todos los recursos que usa CriticalHandle. |
![]() |
Dispose(Boolean) | Libera los recursos no administrados usados por la clase CriticalHandle especificando si se lleva a cabo una operación de eliminación normal. |
![]() |
Equals(Object) | Determina si el objeto especificado es igual al objeto actual.(Heredado de Object). |
![]() |
Finalize() | Libera todos los recursos asociados al identificador.(Invalida CriticalFinalizerObject.Finalize()). |
![]() |
GetHashCode() | Sirve como la función hash predeterminada.(Heredado de Object). |
![]() |
GetType() | Obtiene el Type de la instancia actual.(Heredado de Object). |
![]() |
MemberwiseClone() | Crea una copia superficial del Object actual.(Heredado de Object). |
![]() |
ReleaseHandle() | Cuando se invalida en una clase derivada, ejecuta el código necesario para liberar el identificador. |
![]() |
SetHandle(IntPtr) | Establece el identificador en el identificador preexistente. |
![]() |
SetHandleAsInvalid() | Marca un controlador como no válido. |
![]() |
ToString() | Devuelve una cadena que representa el objeto actual.(Heredado de Object). |
Campos
Nombre | Descripción | |
---|---|---|
![]() |
handle | Especifica el identificador que se va a ajustar. |
Comentarios
The T:System.Runtime.InteropServices.CriticalHandle class is similar to the T:System.Runtime.InteropServices.SafeHandle class, except that T:System.Runtime.InteropServices.SafeHandle implements reference counting. You can use T:System.Runtime.InteropServices.CriticalHandle instead of T:System.Runtime.InteropServices.SafeHandle to address performance considerations when you can provide the necessary synchronization more efficiently yourself.
Because the T:System.Runtime.InteropServices.CriticalHandle class does not perform reference counting, it does not provide protection from handle recycling security attacks. Because the reference counting algorithm implicitly serializes operations, a certain amount of thread safety is also lost. If you call the M:System.IDisposable.Dispose or M:System.Runtime.InteropServices.SafeHandle.Close method while an operation that is using the handle is outstanding on another thread, or if you call M:System.IDisposable.Dispose or M:System.Runtime.InteropServices.SafeHandle.Close from two threads at the same time, the results are non-deterministic. The T:System.Runtime.InteropServices.CriticalHandle class still provides the guaranteed critical finalization provided by the T:System.Runtime.ConstrainedExecution.CriticalFinalizerObject class.
Seguridad
for full trust for inheritors. This member cannot be inherited by partially trusted code.
requires full trust for the immediate caller. This class cannot be used by partially trusted or transparent code.
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 8.0
Windows Phone
Disponible desde 8.1
Seguridad para subprocesos
Cualquier miembro ( Compartido en Visual Basic) estático público de este tipo es seguro para subprocesos. No se garantiza que los miembros de instancia sean seguros para subprocesos.
Ver también
SafeHandle
Microsoft.Win32.SafeHandles
Espacio de nombres System.Runtime.InteropServices
Volver al principio