Created
January 10, 2014 18:56
-
-
Save kumpera/8360360 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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