private ShutDownTimer(Label statusLabel, DateTime shutdownDateTime, ShutdauwnForm shutdawunForm) { ShutDownTimer.instance = this; this.shutdownDateTime = shutdownDateTime; this.statusLabel = statusLabel; this.timerRunning = true; this.shutdawunForm = shutdawunForm; this.timer(); }
private void timerButton_Click(object sender, EventArgs e) { if (ShutDownTimer.TimerStarted) { ShutDownTimer.StopTimer(); this.timerButton.Text = "Start shutdown timer"; this.timerStatusLabel.Text = ""; } else if (minutesUpDown.Value > 0 || hoursUpDown.Value > 0) { ShutDownTimer.StartTimer(this.timerStatusLabel, this, (int)this.minutesUpDown.Value, (int)this.hoursUpDown.Value); this.timerButton.Text = "Stop shutdown timer"; } }
private void timer() { while (this.timerRunning) { if (DateTime.Now >= this.shutdownDateTime) { ShutDownTimer.setStatus(this.statusLabel, "Shutting down"); this.shutdawunForm.Shutdown(); return; } ShutDownTimer.setStatus(this.statusLabel, ShutDownTimer.getTimeLeftString(this.shutdownDateTime)); Thread.Sleep(100); } ShutDownTimer.setStatus(this.statusLabel, ""); }