Итак, код выглядит примерно так:
MAIN(){
/*waiting window class declaration*/
threadinfo* oThread=new threadinfo(); //An object that will help me know when to finish the thread
QueueUserWorkItem((LPTHREAD_START_ROUTINE)waitingWindow, (void*)mThread, WT_EXECUTELONGFUNCTION);
function_that_takes_time();
oThread->setTerminated(); //set member terminated to bool true
/*continue with other things*/
}
и функция waitWindow, которая будет работать в этом потоке
MSG msg;
hwndWaiting=CreateWindow(...) // here the window is created
while (msg.message != WM_QUIT)
{
if (PeekMessage(&msg, null, 0U, 0U, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
if(oThread->isTerminated()) // isTerminated returns bool true if terminated
{
delete oThread;
ExitThread(0);
}
}
}
ExitThread(0);
Является ли ExitThread хорошим способом удаления окна ожидания,и безопасно удалить нить?(по крайней мере, я 100% уверен, , когда закончу).
Я спрашиваю это, потому что это хорошо работает в Windows XP, но завершится с "приложениемперестал работать "на Windows 7.
Спасибо за помощь.