Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
37 lines (30 sloc)
747 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} |