static void MockHeartBeatViaWhileTrue() { while (true) { Console.WriteLine($"Now is {DateTime.Now.ToString("yyyyMMddHHmmssffff")}"); Thread.Sleep(2000); } }
static void HeartBeatViaSystemTimersTimerDemo() { System.Timers.Timer heartBeatTimer = new System.Timers.Timer(2000); heartBeatTimer.Elapsed += HeartBeatTimerElapsed; heartBeatTimer.Start(); } private static void HeartBeatTimerElapsed(object sender, ElapsedEventArgs e) { Console.WriteLine($"Now is {DateTime.Now.ToString("yyyyMMddHHmmssffff")}"); }