CriticalHandle 類別

定義

表示控制代碼資源的包裝函式類別 (Wrapper Class)。Represents a wrapper class for handle resources.

public ref class CriticalHandle abstract : System::Runtime::ConstrainedExecution::CriticalFinalizerObject, IDisposable
[System.Security.SecurityCritical]
public abstract class CriticalHandle : System.Runtime.ConstrainedExecution.CriticalFinalizerObject, IDisposable
type CriticalHandle = class
    inherit CriticalFinalizerObject
    interface IDisposable
Public MustInherit Class CriticalHandle
Inherits CriticalFinalizerObject
Implements IDisposable
繼承
衍生
屬性
實作

備註

類別類似于類別, 但SafeHandle會執行參考計數。 SafeHandle CriticalHandleThe CriticalHandle class is similar to the SafeHandle class, except that SafeHandle implements reference counting. 當您自己CriticalHandle可以更SafeHandle有效率地提供必要的同步處理時, 可以使用而非來解決效能考慮。You can use CriticalHandle instead of SafeHandle to address performance considerations when you can provide the necessary synchronization more efficiently yourself.

CriticalHandle因為類別不會執行參照計數, 所以不會提供保護來處理回收安全性攻擊。Because the 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. 如果您在另IDisposable.Dispose一個Close執行緒上未處理使用控制碼的作業時呼叫或方法, 或者您同時從兩IDisposable.DisposeClose執行緒呼叫或, 則結果會是不具決定性的。If you call the IDisposable.Dispose or Close method while an operation that is using the handle is outstanding on another thread, or if you call IDisposable.Dispose or Close from two threads at the same time, the results are non-deterministic. 類別仍會提供CriticalFinalizerObject由類別提供的保證關鍵最終完成。 CriticalHandleThe CriticalHandle class still provides the guaranteed critical finalization provided by the CriticalFinalizerObject class.

建構函式

CriticalHandle(IntPtr)

使用指定的無效控制代碼值,初始化 CriticalHandle 類別的新執行個體。Initializes a new instance of the CriticalHandle class with the specified invalid handle value.

欄位

handle

指定要包裝的控制代碼。Specifies the handle to be wrapped.

屬性

IsClosed

取得值,指出控制代碼是否已關閉。Gets a value indicating whether the handle is closed.

IsInvalid

在衍生類別中覆寫時,取得值以指出這個控制代碼值是否無效。When overridden in a derived class, gets a value indicating whether the handle value is invalid.

方法

Close()

標記要釋出和釋放資源的控制代碼。Marks the handle for releasing and freeing resources.

Dispose()

釋放 CriticalHandle 所使用的所有資源。Releases all resources used by the CriticalHandle.

Dispose(Boolean)

釋放 CriticalHandle 類別所使用的 Unmanaged 資源,指定是否要執行一般處置 (Dispose) 作業。Releases the unmanaged resources used by the CriticalHandle class specifying whether to perform a normal dispose operation.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
Finalize()

釋放與控制代碼相關的所有資源。Frees all resources associated with the handle.

GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
ReleaseHandle()

在衍生類別中覆寫時,執行釋放控制代碼所需的程式碼。When overridden in a derived class, executes the code required to free the handle.

SetHandle(IntPtr)

將控制代碼設定為指定的既有控制代碼。Sets the handle to the specified pre-existing handle.

SetHandleAsInvalid()

將控制代碼標記為無效。Marks a handle as invalid.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

安全性

InheritanceDemand
適用於繼承者的完全信任的。for full trust for inheritors. 部分信任的程式碼無法繼承這個成員。This member cannot be inherited by partially trusted code.

SecurityCriticalAttribute
需要完全信任立即呼叫者。requires full trust for the immediate caller. 這個類別無法由部分信任或透明的程式碼使用。This class cannot be used by partially trusted or transparent code.

適用於

另請參閱