private void WorkerThread()
{
AppConsole.Log("Restarter Worker Thread Started", ConsoleColor.Green);
DateTime nextRestart = GetRestartTime(); //--- Fetch next restart
AppConsole.Log(String.Format("Selected next restart date: {0}", nextRestart.ToString("F")), ConsoleColor.Green);
_workerRunning = true;
while (_workerRunning) {
_waitHandle.WaitOne(1000);
TimeSpan timeLeft = nextRestart.Subtract(DateTime.Now);
SendMessage(String.Format("Time until next restart: {0} hours, {1} minutes, {2} seconds.",
timeLeft.Hours, timeLeft.Minutes, timeLeft.Seconds));
if (timeLeft.CompareTo(TimeSpan.Zero) < 0)
DoRestart();
}
Basically from this thread I need to output a message every 5 minutes if the server is more than 10 minutes from restarting and output a message every 2.5 minutes if the server is under 10 minutes from starting. I'm just wondering what would be the best way to do this.
Cheers