In class I showed and example CountDownTimer. In this example you start a timer, that counts down to zero. At each "tick" it sends an event.
In this exercise you are going to make something similar. You must program a class Clock that fires an event with certain intervals (like every second). The Clock never stops (unlike the CountDownTimer).
First you are going to make a class similar to TickEventArgs from the CountDownTimer example.
Make a class TimeEventArgs. This class must have a property
public DateTime TimeNow { get; private set; }
The value of the property must be initialized in the constructor, use DateTime.Now
to get the current time.
Next you are going to make a class similar to CountDownTimer.
Make a class Clock. Some fragments that might be useful
public event EventHandler Tick;
public void Start() { new Thread(() => { while (true) { ... Thread.Sleep(1000); } }.Start(); }
In th main make an object of the Clock class, and add one or more event handlers to the Clock.Tick event.
The event handler(s) can do Console.WriteLine(...)
Add another event handler: This handler is only going to do Console.WriteLine(...) every 10 seconds.
In the current version I assume the time between Tick is 1000 msec (1 second).
Adapt the class Clock so that the time can very according to a parameter to the Clock constructor.
For backward compatibility you can assign this parameter a default value.
Help (section "Optional Arguments)
Problem: I assume you made Visual Studio Solution a Console Application.This means that you cannot make GUI applications.
Solution: Add another project to the EXISTING Solution: Right click the Solution and "New Project ...", choose WPF