1 min read

Working with timers in .NET Part 2 – Hook up the Elapsed event for the timer

Now let’s make our timer print out some information every 2 seconds.

First create a static method that displays the ElapsedEventArgs property e.SignalTime.

Next hook up the elapsed event for the timer.

Finally inside the main method call the methods to stop and dispose to stop raising the events and release the resources used by the timer.

Awesome! Now let’s run the app and check our our timer.

Great work! Now go our and create some timers! It’s free!

Leave a Reply