Example Using a Timer to perform a simple countdown.

suggest change
public partial class Form1 : Form
{

Timer myTimer = new Timer();
int timeLeft = 10;

    public Form1()
    {
        InitializeComponent();

        //set properties for the Timer
        myTimer.Interval = 1000;
        myTimer.Enabled = true;

        //Set the event handler for the timer, named "myTimer_Tick"
        myTimer.Tick += myTimer_Tick;

        //Start the timer as soon as the form is loaded
        myTimer.Start();

        //Show the time set in the "timeLeft" variable
        lblCountDown.Text = timeLeft.ToString();

    }

    private void myTimer_Tick(object sender, EventArgs e)
    {
        //perform these actions at the interval set in the properties.
        lblCountDown.Text = timeLeft.ToString();
        timeLeft -= 1;

        if (timeLeft < 0)
        {
            myTimer.Stop();
        }
    }
}

Results in…

And so on…

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Timers:
* Timers
* Example Using a Timer to perform a simple countdown.

Table Of Contents
17 Regex
19 Arrays
21 Enum
22 Tuples
24 GUID
27 Looping
36 Casting
46 Methods
88 Events
92 Structs
104 Indexer
106 Stream
107 Timers
109 Threading
127 Caching
135 Pointers
147 C# Script