-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathSampleWorker.cs
More file actions
37 lines (30 loc) · 747 Bytes
/
SampleWorker.cs
File metadata and controls
37 lines (30 loc) · 747 Bytes
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
using System;
using System.Threading;
class Program
{
public static bool running;
public static void Log(string s)
{
Console.WriteLine($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] {s}");
}
public static void Loop()
{
Log("Started SampleWorker(c# version), press Enter to exit");
while (running)
{
Log("Running");
Thread.Sleep(1000);
}
Log("Stopped SampleWorker(c# version)");
}
public static void Main()
{
var th = new Thread(Loop);
running = true;
th.Start();
var msg = Console.ReadLine();
Log($"Received message \"{msg}\" from the Monitor");
running = false;
th.Join();
}
}