private void ShutDownTm_Tick(object sender, EventArgs e) { timeLeft = timeLeft.Subtract(TimeSpan.FromSeconds(1)); lblTimer.Text = timeLeft.ToString(@"hh\:mm\:ss"); if (timeLeft.TotalSeconds <= 0) { ShutDownTm.Stop(); PerformAction(); } }
private void button1_Click(object sender, EventArgs e) { CheckTextBoxValues(); bool isStartable = true; try { timeLeft = new TimeSpan(Convert.ToInt32(Hours.Text), Convert.ToInt32(Mins.Text), Convert.ToInt32(Secs.Text)); } catch (FormatException) { isStartable = false; MessageBox.Show("False Format!"); } if (isStartable == true) { ShutDownTm.Start(); lblTimer.Text = timeLeft.ToString(@"hh\:mm\:ss"); } }
private void button2_Click(object sender, EventArgs e) { ShutDownTm.Stop(); }