GCHandle.IsAllocated Property


Gets a value indicating whether the handle is allocated.

Namespace:   System.Runtime.InteropServices
Assembly:  mscorlib (in mscorlib.dll)

Public ReadOnly Property IsAllocated As Boolean

Property Value

Type: System.Boolean

true if the handle is allocated; otherwise, false.

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.

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top