Why there are 5 Versions of Timer Classes in .NET?
.net, c#, timer
Solution
Here's a description of the primary timers and the points that i find to be the most noteworthy.
`Winforms.Timer`
- ticks on UI thread
- ticks delayed until UI thread is idle
- will skip ticks if the UI thread is busy long enough for multiple ticks to pile up
`DispatcherTimer`
- invoked on UI thread
- can set priority for what level of 'idle' is required to generate a tick
- will skip ticks if they pile up
`Threading.Timer`
- ticks on a worker thread from threadpool - no option for specifying thread
- ticks are always fired on time
- none are skipped - you must guard against new ticks while you're still processing a former tick
- unhandled exceptions will crash the application
`Timers.Timer`
- wrapper around threading timer
- ticks on a worker thread taken from the CLR threadpool
- can force to tick on a specific thread by supplying a SynchronizationObject
- ticks are always fired on time
- none are skipped
- silently eats exceptions
Problem
Why are there five timer classes in the .Net framework, namely the following: - `System.Timers.Timer` - `System.Threading.Timer` - `System.Windows.Forms.Timer` - `System.Web.UI.Timer` - `System.Windows.Threading.DispatcherTimer` Why are there several versions of the Timer class? And what are the differences between them?