I made a thread on a load event, as shown below:
Thread checkAlert = null;
bool isStop = false;
private void frmMain_Load(object sender, EventArgs e)
{
checkAlert = new Thread(CheckAlert);
checkAlert.Start();
}
void CheckAlert()
{
while (!isStop)
{
Thread.Sleep(60000);
}
}
Is there a way to resume checkAlert flow during this sleep period? ( Thread.Sleep(60000);)
I tried using Thread.Interrupt(), but it passes a ThreadInterruptedException, how should I handle this exception? or is there a way to resume the flow?
Edited by:
I need to wake the thread until the end of the "sleep", because when the user wants to exit the program, the program will have to wait a while before it really leaves (checkAlert still works). Is there any way to improve this case?
source
share