Listing 1

{
//Create a reference to an object as you normally would.
Object oMyObj = new Object();

//Create the weak reference as soon as possible.
WeakReference oWR = new WeakReference(oMyObj);

oMyObj = null; //Drop the reference to the strong object.

oMyObj = wr.Target; //Use the target of the weak reference.
If (oMyObj == null)
{
//If oMyObj is null then the GC cleaned it up and you need
//to recreate the object and start over. Nice way to manage
//object references for things that are expensive to create.
}
Else
{
//If oMyObj is not null then it is still active and the GC 
//didn't clean up the object yet. Use it as you normally 
//would and party on.
}