[threads] Don't ignore abort requests in abort protected blocks
[mono-project.git] / mono / tests / sleep.cs
blob0d2110898cc8c9cc4ea139451f7d3837ad8ec701
1 using System;
2 using System.Threading;
3 using System.Diagnostics;
5 public class Tests
7 static bool finished;
9 public static int Main (String[] args) {
10 return TestDriver.RunTests (typeof (Tests), args);
13 public static int test_0_time_drift () {
14 // Test the Thread.Sleep () is able to deal with time drifting due to interrupts
15 Thread t = new Thread (delegate () {
16 while (!finished)
17 GC.Collect ();
18 });
19 t.Start ();
21 var sw = Stopwatch.StartNew ();
22 Thread.Sleep (1000);
23 finished = true;
24 sw.Stop ();
25 if (sw.ElapsedMilliseconds > 2000) {
26 Console.WriteLine (sw.ElapsedMilliseconds);
27 return 1;
28 } else {
29 return 0;