D. Timers Prior to the Async/Await Pattern of C# 5.0
Chapter 19 introduced the use of Task.Delay()
when a timer was required. For scenarios prior to .NET 4.5, several timer classes are available, including System.Windows.Forms.Timer
, System.Timers.Timer
, and System.Threading.Timer
.
The development team designed System.Windows.Forms.Timer
specifically for use within a rich client user interface. Programmers can drag it onto a form as a nonvisual control and regulate the behavior from within the Properties window. Most importantly, it will always safely fire an event from a thread that can interact with the user interface.
The other two timers are very similar. System.Timers.Timer
is a wrapper for System.Threading.Timer
, abstracting and layering ...
Get Essential C# 5.0 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.