This is a little tricky. It depends on how you use the thread. If you are going to create the thread many times in a program instance, you need to be careful. If you just create the thread when the program starts up and destroy the thread when the program ends, you can just call Terminate().
I like to do a simple series of calls to end a thread.
if (MyThread)
{
while (MyThread->Suspended())
MyThread->Resume();
MyThread->Terminate();
MyThread->WaitFor();
delete MyThread;
MyThread = NULL;
}
This will almost always guarentee a clean eradication of the thread so that it may be used again later. Also, when you create the thread:
if (!MyThread)
MyThread = new MyThread(TrueOrFalse);
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.