countdown timer problem

  • Thread starter Thread starter JavadR
  • Start date Start date
J

JavadR

Guest
hi guys

i make countdown timers , after 10 secounds int count * 2 and again reset countdown timers.

i want 5 time per 10 sec count * 2 and in time 5 stop timer.

private DateTime startTime;
private void Form1_Load(object sender, EventArgs e)
{
label1.Text = TimeSpan.FromSeconds(10).ToString("dd\\:hh\\:mm\\:ss");
timer1.Interval = 1000;
}

public void counter()
{
int count = 300;
count = count * 2;
label2.Text = count + " $";
label1.Text = (TimeSpan.FromSeconds(10) - (DateTime.Now - startTime)).ToString("dd\\:hh\\:mm\\:ss");
startTime = DateTime.Now;
timer1.Start();

}
private void timer1_Tick(object sender, EventArgs e)
{
if(timer1.Interval <= 0)
{
counter();
}
else
{
label1.Text = (TimeSpan.FromSeconds(10) - (DateTime.Now - startTime)).ToString("dd\\:hh\\:mm\\:ss");
}


}

private void button1_Click(object sender, EventArgs e)
{
startTime = DateTime.Now;
timer1.Start();
}

Continue reading...
 
Back
Top