Retrieves a Boolean that indicates whether GC has occurred on the object.
[Visual Basic] Overridable Public ReadOnly Property IsAlive As Boolean [C#] public bool IsAlive {virtual get;} [C++] public: __property virtual bool get_IsAlive(); [JScript] public function get IsAlive() : Boolean;
Read only. This property can have the following values:
Value | Description |
---|---|
true | The object is still accessible. |
false | Otherwise. |
Exception Type | Condition |
---|---|
WeakReferenceException | If the object reference encapsulated by the current instance is invalid. |
The Is Alive property retrieves a Boolean that indicates whether the current instance of WeakReference still refers to an object that has or has not been collected by the garbage collector (GC) yet.
If IsAlive returns true, the Target property will return a valid reference to the object. On the other hand, if IsAlive returns false, Target returns null.
A WeakReferenceException is thown if the the object reference encapsulated by the current instance is invalid. This will occur if the current instance has been resurrected after a call to Finalize because Finalize destroys the underlying reference.
WeakReference Class | WeakReference Members | System Namespace | GC | GCHandle | Object