Click to See Complete Forum and Search --> : Program is closed, but the process never ends!


Fatboy
October 24th, 2004, 10:01 AM
This problem has always bugged me. See, sometimes I would write a program compatible with Windows XP, and run it, and close it. But the things is, running it and closing it are both fine, but with some programs I Write, even if the execution file is close, the process is still running under the processes tab in Windows task manager! I'm pretty sure it's something to do with the message loop, but I don't know exactly what's wrong. Can anybody help me?

gstercken
October 24th, 2004, 10:05 AM
This problem has always bugged me. See, sometimes I would write a program compatible with Windows XP, and run it, and close it. But the things is, running it and closing it are both fine, but with some programs I Write, even if the execution file is close, the process is still running under the processes tab in Windows task manager! I'm pretty sure it's something to do with the message loop, but I don't know exactly what's wrong. Can anybody help me?There can be many reasons for that - addidional threads which are not ended, windows which are just closed or hidden without ending the process... Hard to be more specific without seeing any code.

japheth
October 26th, 2004, 02:05 AM
First I would check if the app is exiting the message loop.
This can be done by using a debugger or displaying something with OutputDebugString and using dbgview.exe.

Second, if the message loop has been exited, but the process still doesn't terminate, check if ExitProcess is executed by your app. During the exit process, all dlls are called with reason DLL_DETACH_PROCESS, and this may, under certain conditions, cause a deadlock!

Bond
October 27th, 2004, 04:50 PM
If you're using a modal dialog, be sure to call EndDialog().

If you're using a modeless dialog or a typical Windows window, be sure to use PostQuitMessage().

Both, in the end, will send a WM_QUIT message to your message queue while will cause your message loop to exit and eventually return from WinMain.

rafraf
October 28th, 2004, 09:03 AM
As mentioned above, you should check the program's main loop.
Look for GetMessage or PeakMessage and Debug it.
Usually GetMessage controls the loop and if it receives the WM_QUIT. when you use something else to control your main loop like PeakMessage you should take take care when closing you programs.
anyway you should debug.