Usually, you set up some kind of inter-thread communication in your thread procedure.
For instance, if you're using
PostThreadMessage()
:
DWORD WINAPI ThreadProc(LPVOID pX)
{
if (pX != NULL)
{
X *realPointer = reinterpret_cast<x> pX;
::PeekMessage(whatever);
while (!done)
{
::GetMessage(....)
switch(msg.uMsg)
{
case WM_COMMAND: realPointer->ExecuteCommand(msg.lParam);
break;
case WM_QUIT: done = true;
break;
}
} SetEvent(realPointer->reallyDone);
} return 0;
}
</x>
In any case, the server thread and the client thread must be able to communicate. Google for 'thread design patterns'.
If you're using 'shoot and forget' threads, you can kill them violently, but this is a bad thing. Your best option, depending on your actual circumstances, may be to hide your main window, and just wait for all threads to complete execution.
Hope this helps,
Pablo.