GCHandle.IsAllocated Property

Definition

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

Property Value

true if the handle is allocated; otherwise, false.

Remarks

Use this property when using Weak handles to determine if the GCHandle is still available. 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.

Applies to

See also