public void MakeTheTick() { String timeNow = DateTime.Now.ToString("hh:mm:ss"); ClockTime args = new ClockTime(); Tick(this, args); }
void TimeGoes(object sender, ClockTime args) { while (true) { Console.WriteLine(DateTime.Now.ToLongTimeString()); Thread.Sleep(1000); } }
public void MakeTheAlarm(int h, int m, int s) { ClockTime args = new ClockTime() { Hour = h, Minute = m, Second = s }; Alarm(this, args); }
void TimeIsUp(object sender, ClockTime args) { while (true) { String timeNow = DateTime.Now.ToString("hh:mm:ss"); try { Console.WriteLine(timeNow); if (args.Hour == Convert.ToInt32(timeNow.Substring(0, 2)) && args.Minute == Convert.ToInt32(timeNow.Substring(3, 2)) && args.Second == Convert.ToInt32(timeNow.Substring(6, 2))) { Console.WriteLine("RING...RING...RING...RING...RING...RING...RING..."); } } catch { Console.WriteLine("error"); } Thread.Sleep(1000); } }