GCHandle.IsAllocated GCHandle.IsAllocated GCHandle.IsAllocated GCHandle.IsAllocated Property

定義

取得值,指出控制代碼是否已配置。Gets a value indicating whether the handle is allocated.

public:
 property bool IsAllocated { bool get(); };
public bool IsAllocated { get; }
member this.IsAllocated : bool
Public ReadOnly Property IsAllocated As Boolean

屬性值

如果已配置控制代碼,則為 true,否則為 falsetrue if the handle is allocated; otherwise, false.

備註

使用Weak控制碼來判斷GCHandle是否仍然可用時,請使用這個屬性。Use this property when using Weak handles to determine if the GCHandle is still available. 當垃圾收集行程收集物件時,此Weak控制碼仍然可以在完成項中 isdefunct。When the garbage collector collects the object, the Weak handle can still be resurrected in the finalizer. 在這種情況下,就不會配置控制碼(當垃圾收集行程嘗試收集物件時,它會遺失),即使目標物件是有效的也一樣。In that case, the handle is not allocated (it is lost when the garbage collector attempts to collect the object), even though the target object is valid.

適用於

另請參閱