Fix calling await on base expressions
[mono.git] / mono / tests / finalizer-wait.cs
1 using System;
2 using System.Threading;
3 using System.Runtime.ConstrainedExecution;
4
5 class P {
6
7         static public int count = 0;
8         ~P () {
9                 T.finalized = true;
10                 Thread.Sleep (1000);
11                 //Console.WriteLine ("finalizer done");
12                 count++;
13         }
14 }
15
16 class T {
17
18         static public bool finalized = false;
19
20         static void makeP () {
21                 P p = new P ();
22                 p = null;
23         }
24
25         static void callMakeP () {
26                 makeP ();
27         }
28
29         static int Main () {
30                 callMakeP ();
31
32                 GC.Collect ();
33                 while (!finalized) {
34                         Thread.Sleep (100);
35                 }
36                 GC.WaitForPendingFinalizers ();
37
38                 if (P.count == 0)
39                         return 1;
40                 return 0;
41         }
42 }