I am running a thread that does something, then sleeps for a while. If the program closes it continues to sleep to completion. How do I get it to abort immediatly, even if in the middle of sleeping?
void commThread::ThreadEntryPoint1()
{
while(1)
{
//do work
Sleep(15000); //15 second sleep
}
}
and in my mainform destructor which controls the thread:
~Form1()
{
if (components)
{
delete components;
}
if(Thread1->IsAlive)
{
//Thread1->Interrupt();
Thread1->Abort();
}
}
Thanks.