Skip to content

Instantly share code, notes, and snippets.

@kumpera
Created January 10, 2014 18:56
Show Gist options
  • Select an option

  • Save kumpera/8360360 to your computer and use it in GitHub Desktop.

Select an option

Save kumpera/8360360 to your computer and use it in GitHub Desktop.
using System;
using System.Threading;
class Driver {
static WeakReference wr;
~Driver () {
Console.WriteLine ("fin");
}
static void Main () {
var t = new Thread(() => { wr = new WeakReference (new Driver ()); });
t.Start ();
t.Join ();
Console.WriteLine (wr.IsAlive);
GC.Collect ();
Console.WriteLine (wr.IsAlive);
GC.WaitForPendingFinalizers ();
Console.WriteLine (wr.IsAlive);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment