I'm trying to get a timer to tick once a second in a winform, when I look for advice on how to do this I find loads of stuff about threads. Well I don't care about threads, because all I'm trying to do is make a value count down from 60 to 0 in one minute, then stop. I don't think we need to go into cloud computing to solve this one, but I am really a web forms bod, so I'm a bit rusty on this issue. Can anyone point me to an example
Here's what I tried
private void button1_Click(object sender, EventArgs e)
{
this.timeLeft = 60;
this.label1.Visible = false;
this.button1.Visible = false;
gt = new Timer();
gt.Tick += new EventHandler(CountDown);
gt.Interval = 1000;
gt.Start();
}
private void CountDown(object sender, EventArgs e)
{
do
{
this.TimeBar.Value = timeLeft;
this.timeLeft -= 1;
} while (this.timeLeft > 0);
if (this.TimeBar.Value > 0) return;
gt.Stop();
this.label1.Visible = true;
this.button1.Visible = true;
}
Any help would be appreciated.