O'Reilly logo

Essential C# 5.0 by Eric Lippert, Mark Michaelis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required