I was researching timers the other day and realized that there are three variations in the .NET Framework.

The three types of timers are explained below.
1 – System.Timers.Timer
The System.Timers.Timer class timer is considered a server-based timer that was designed and optimized for use in multithreaded environments. It can be accessed safely from multiple threads.
Source Code
Output
–
2 – System.Threading.Timer
The System.Threading.Timer class timer uses a TimerCallBack Delegate to specify the associated methods. The methods do not execute in the thread that created the timer; they execute in a separate thread that is automatically allocated by the system.
Source Code
Output
–
3 – Windows.Forms.Timer
The Windows.Forms.Timer class works synchronously with the Windows Form, so that it will not interrupt any operations. It initializes on the UI thread.
Source Code
Output
–
There are three choices for timers in .NET. It just depends on what you want to do.
–
More Information
- Comparing the Timer Classes in the .NET Framework Class Library
- System.Timers.Timer vs System.Threading.Timer
- Working with Timer Control in VB.NET
–
Until next time…
[...] Timers in .NET (Rhonda Tipton) [...]
By: Dew Drop – November 7, 2009 | Alvin Ashcraft's Morning Dew on November 7, 2009
at 7:36 am
hhhmmm I initially read your blog post cause I was looking for the differences in why/when to use the different timers. Unfortunately just as I get to the “…depends on what you want to do” you end the post. DOH! Can you expand on this please?
By: phenry9999 on November 9, 2009
at 10:18 am
@phenry9999 – I meant this to be a complete beginner post. I am researching the why/when and was planning on doing another post…hopefully in the near future. There is not a ton of info on the differences.
By: Rhonda on November 9, 2009
at 9:46 pm
Thanks for the response. Very cool, I subscribed to your rss feed, can’t wait for the update. Thanks for looking into this (I hope :>HAHA). Have a good day!
By: phenry9999 on November 10, 2009
at 8:42 am