How to make a timer which forces the application to close at a specified time in C#? I have something like this:
void myTimer_Elapsed(object sender, System.
Set up your timer to check every second like now, but swap the contents with:
void myTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (DateTime.Now.Hour == 23)
this.Close();
}
This will make sure that when the timer run and the clock is 23:xx, then the application will shut down.