[interp] properly pass 64bit integers to native code on 32bit arches
[mono-project.git] / mono / tests / thread-suspend-selfsuspended.cs
blob02a63a4bb39acc2047dfa40ac05bda0be3e442be
2 using System;
3 using System.Threading;
5 class Driver
7 public static void Main ()
9 bool finished = false;
10 int can_gc = 0;
12 Thread t1 = Thread.CurrentThread;
14 Thread t2 = new Thread (() => {
15 while (!finished) {
16 int local_can_gc = can_gc;
17 if (local_can_gc > 0 && Interlocked.CompareExchange (ref can_gc, local_can_gc - 1, local_can_gc) == local_can_gc)
18 GC.Collect ();
20 try {
21 t1.Resume ();
22 } catch (ThreadStateException) {
25 Thread.Yield ();
27 });
29 t2.Start ();
31 Thread.Sleep (10);
33 for (int i = 0; i < 50 * 40 * 5; ++i) {
34 Interlocked.Increment (ref can_gc);
35 Thread.CurrentThread.Suspend ();
36 if ((i + 1) % (50) == 0)
37 Console.Write (".");
38 if ((i + 1) % (50 * 40) == 0)
39 Console.WriteLine ();
42 finished = true;
44 t2.Join ();