First add a label and timer to a form :
timer Properties :
this.timer1.Enabled = true;
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
declare this globally :
private int hh;
private int mm;
private int ss;
In form_Load event add :
private void Form1_Load(object sender, EventArgs e)
{
int hours = 360 / 60;
int minutes = 360 % 60;
hh = hours;
mm = minutes;
ss = 59;
}
In timer_tick event add this code:
String Hours;
String Minutes;
String Seconds;
ss = ss - 1;
Hours = (hh < 10) ? "0" + hh.ToString() : hh.ToString();
Minutes = (mm < 10) ? "0" + mm.ToString() : mm.ToString();
Seconds = (ss < 10) ? "0" + ss.ToString() : ss.ToString();
label1.Text = Hours + " : " + Minutes + " : " + Seconds;
if (Seconds == "00" && Minutes == "00" && Hours == "00")
{
timer1.Enabled = false;
this.Enabled = false;
Application.Exit();
}
if (ss == 0 && mm == 0)
{
ss = 60;
mm = 59;
hh = hh - 1;
}