The Timer control allows you to set a time interval to peridically execute an event at a specified interval. It is useful when you want to execute certain applications after a certain interval. Say you want to create a hourly backup of your data. You can make a routine that will take the backup and call that routine in the Timer's event and set the timer interval for an hour.

Using timer control is very simple. To demonstrate this I am going to make an application in which 5 seconds after button click a message box will be displayed “Timer working”.

To use timer control drag and drop timer control from tool box to the form.

Timer in C Sharp


Code at button click event.

private void btnClick_Click(object sender, EventArgs e)
//setting interval of timer to 5000 miliseconds.
//1000 miliseconds = 1 sec
//so 5000miliseconds = 5 sec.
            timer1.Interval = 5000;
//starting timer.
            timer1.Enabled = true;
//code for timer tick event
        private void timer1_Tick(object sender, EventArgs e)
//displaying message box.
            MessageBox.Show("Timer Working");
//stoping timer.
            timer1.Enabled = false;           
Screen shot

Timer in C Sharp

Member of timer

This event occurs when the Interval has elapsed. 
Starts raising the Tick event by setting Enabled to true. 
Stops raising the Tick event by setting Enabled to false. 
Releases the resources used by the Timer. 
Indicates whether the Timer raises the Tick event each time the specified Interval has elapsed or whether the Tick event is raised only once after the first interval has elapsed.
Indicates the interval on which to raise the Tick event.
Indicates whether the Timer raises the Tick event.


  Modified On Jul-17-2019 06:13:48 AM
  1. Your words increase my knowledge for sure. Thanks

    Keep sharing these types of articles.

Leave Comment