SafeHandle.SetHandleAsInvalid Method

Definition

将句柄标记为不再使用。Marks a handle as no longer used.

public:
 void SetHandleAsInvalid();
[System.Security.SecurityCritical]
public void SetHandleAsInvalid ();
public void SetHandleAsInvalid ();
member this.SetHandleAsInvalid : unit -> unit
Public Sub SetHandleAsInvalid ()
Attributes

Remarks

仅当你知道句柄不再引用资源时,才调用 SetHandleAsInvalid 方法。Call the SetHandleAsInvalid method only when you know that your handle no longer references a resource. 这样做不会更改 "handle" 字段的值;它仅将句柄标记为已关闭。Doing so does not change the value of the handle field; it only marks the handle as closed. 该句柄可能会包含可能的陈旧值。The handle might then contain a potentially stale value. 此调用的效果是,不会尝试释放资源。The effect of this call is that no attempt is made to free the resources.

SetHandle 方法一样,仅当需要支持预先存在的句柄时才使用 SetHandleAsInvalidAs with the SetHandle method, use SetHandleAsInvalid only if you need to support a pre-existing handle.

Applies to