2010-04-07 Rodrigo Kumpera <rkumpera@novell.com>
[mono-project.git] / mono / tests / finalizer-wait.cs
bloba730b5403dedb32b708a3cb8cf273fb0e429981d
1 using System;
2 using System.Threading;
3 using System.Runtime.ConstrainedExecution;
5 class P {
7 static public int count = 0;
8 ~P () {
9 T.finalized = true;
10 Thread.Sleep (1000);
11 //Console.WriteLine ("finalizer done");
12 count++;
16 class T {
18 static public bool finalized = false;
20 static void makeP () {
21 P p = new P ();
22 p = null;
25 static void callMakeP () {
26 makeP ();
29 static int Main () {
30 callMakeP ();
32 GC.Collect ();
33 while (!finalized) {
34 Thread.Sleep (100);
36 GC.WaitForPendingFinalizers ();
38 if (P.count == 0)
39 return 1;
40 return 0;