forked from nomi-san/parsec-vdd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Daemon.cs
42 lines (34 loc) · 980 Bytes
/
Daemon.cs
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
using System;
using System.Threading;
namespace ParsecVDisplay
{
internal static class Daemon
{
static Thread EventThread;
static CancellationTokenSource Cancellation;
public static void Start()
{
Cancellation = new CancellationTokenSource();
var token = Cancellation.Token;
EventThread = new Thread(() => EventLoop(token));
EventThread.IsBackground = false;
EventThread.Priority = ThreadPriority.Highest;
EventThread.Start();
}
public static void Stop()
{
Cancellation?.Cancel();
EventThread?.Join();
}
static void EventLoop(CancellationToken cancellation)
{
while (true)
{
if (cancellation.IsCancellationRequested)
break;
ParsecVDD.Ping();
Thread.Sleep(100);
}
}
}
}