blob: 689ef82cdca056b069785860619c59846fc4c50c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace EEGC{
using System;
using System.Threading;
public class SleepThread{
private static int m_sleepTime;
public static bool shouldContinue;
public SleepThread(int time){
m_sleepTime = time;
}
public static void ThreadStart(){
run();
}
public static void run(){
long tElapsed, t1, t2;
int cIteration;
cIteration = 0;
while(Volatile.Read(ref shouldContinue))
{
cIteration++;
t1 = Environment.TickCount;
Thread.Sleep(m_sleepTime);
t2 = Environment.TickCount;
if(t2 - t1 > m_sleepTime * 1.4)
{
tElapsed = t2 - t1;
#if VERBOSE
Console.WriteLine("Thread 2. Iteration " + cIteration + ". " + tElapsed + "ms elapsed");
#endif
}
}
}
}
}
|