Original Post
My program used to be a single thread (win32 application) that ran an infinite loop :
ZeroMemory(&Msg, sizeof(MSG));
while(Msg.message != WM_QUIT) {
if(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) {
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
else {
if(mymain.DrawFrame() == FALSE) break;
}
}
with the message handling:
long FAR PASCAL WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch(uMsg) {
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
};
When I pressed "esc" or clicked the "X" button it closed the program and killed the process.
I''ve added multithreading to my program though. Basically the program instanstiates a thread that loads all of the data, and while that thread is running it shows a title screen and a progress bar. Now my infinite loop looks like this:
ZeroMemory(&Msg, sizeof(MSG));
while(Msg.message != WM_QUIT) {
if(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) {
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
else {
if(mymain.IsRunning()) mymain.RenderTitleScreen();
else {
if(mymain.DrawFrame() == FALSE) break;
}
}
}
IsRunning() is a function that returns true if the loading thread is still running.
So that''s it, when the thread is done it calls CloseHandle(d_threadhandle) and the game continues normally. But now whenever I close the program, the window closes but the process does not terminate!!! This is VERY annoying as every time I run my program I have to go into the task manager and close the process myself. Any ideas why the process isn''t killing itself when it was before? Thanks.