Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / sleep.cs
1 using System;
2 using System.Threading;
3 using System.Diagnostics;
4
5 public class Tests
6 {
7         static bool finished;
8
9         public static int Main (String[] args) {
10                 return TestDriver.RunTests (typeof (Tests), args);
11         }
12
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 ();
20
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;
30                 }
31         }
32 }