SafeHandle.SetHandleAsInvalid 方法

定义

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

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

注解

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

安全性

SecurityPermission
用于调用非托管代码的权限。for permission to call unmanaged code. 安全操作: LinkDemandSecurity action: LinkDemand. 关联的枚举:UnmanagedCodeAssociated enumeration: UnmanagedCode

适用于