Skip to content

Instantly share code, notes, and snippets.

@kumpera
Created September 24, 2013 21:20
Show Gist options
  • Select an option

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

Select an option

Save kumpera/6691428 to your computer and use it in GitHub Desktop.
using System;
namespace ConsoleApplication8
{
class Program
{
static object value;
static void Main (string[] args)
{
WeakReference weak = null;
var v = new System.Threading.Thread (() => { value = new object(); weak = new WeakReference (value); });
v.Start (); v.Join ();
value = null;
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
Console.WriteLine (weak.IsAlive);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment