Hi Priya,
The .NET Framework Class Library (FCL) includes four classes named Timer, each of which offers different functionality:
- System.Timers.Timer: it fires an event and executes the code in one or more event sinks at regular time intervals. The class is intended for use as a server-based or service component in a multithreaded environment; it has no user interface (not UI) and is not visible at runtime. For server-based timer functionality, you might consider using System.Timers.Timer, which raises events and has additional features. For example, suppose you have a critical server that must be kept running 24 hours a day, 7 days a week, 365 days a year. You could create a service that uses a Timer object to periodically check the server and ensure that the system is up and running. If the system is not responding, the service could attempt to restart the server or notify an administrator or something like that.
- System.Threading.Timer: it executes a single callback method on a thread pool thread at regular time intervals. The callback method is defined when the timer is instantiated and cannot be changed later. Like the System.Timers.Timer class, this class is intended for use as a server-based or service component in a multithreaded environment; it has no user interface and is not visible at runtime.
- System.Windows.Forms.Timer: It is a Windows Forms component that fires an event and executes the code in one or more event sinks at regular intervals. The component has no user interface and is designed for use in a single-threaded environment.
- System.Web.UI.Timer: It is an ASP.NET component that performs asynchronous or synchronous web page postbacks at a regular interval. It is a UI timer.
Posted On:
25-Mar-2016 01:35