WeakReference

WeakReference


Provides a reference to an object, but does not keep that object alive.


Remarks

This is to help with circular references to prevent unreachable objects from remaining in memory. The number of references is examined after each call to an objects IUnknown.Release method. Once it reaches zero, the WeakReference object clears the hook into the referenced object and sets the IsAlive status to false.

See Also

Project VBCorLib Overview | Constructors

Implements:

IObject 

Public:

Properties:

NameDescription
 IsAlive (get)Returns the status of the weakly referenced object. 
 IsChild (get)Returns if this isnstance of WeakReference is a child. 
 Target (get)Returns a strong reference to the object a weak reference is being kept to. 
 Target (set)Sets the target object to keep a weak reference to. 

Methods:

NameDescription
 ClearDeadReferencesReleases any dead child WeakReferences. 
 CreateChildCreates a new weak reference without allocating addition resources to maintain reference integrity. 
 DisposeReleases the reference to the Target object. 
 EqualsReturns a boolean indicating if the value and this object instance are the same instance. 
 GetHashCodeReturns a pseudo-unique number identifying this instance. 
 ToStringReturns a string representation of this object instance. 

Events:

NameDescription
 DisposedThis event is raised when a controlling WeakReference loses reference to the underlying Target object.