static void Demo1() { var alarmInterval = 500; var clock = new AlarmClock(alarmInterval); clock.OnAlarmRaised += AlarmTickHandler1; clock.OnAlarmRaised += AlarmTickHandler2; Console.WriteLine($"Created alarm with an interval of {alarmInterval} ms."); Console.WriteLine("Press any key to start the clock..."); Console.ReadKey(); if (clock.StartClock()) { Console.WriteLine("Clock started. Press any key to stop..."); } else { throw new Exception("Could not start!"); } Console.ReadKey(); if (clock.StopClock()) { Console.WriteLine("Alarm stopped."); } else { throw new Exception("Could not stop."); } }