Program not responding message when trying to exit

Hello,

I am upgrading an older program that is divided into several processes, there one is just a command window that handles some serial communication. Everything works fine, but if I press the X button to exit the window I get after a few seconds the "program is not responding message". I have not written the program myself so I don't know all the details on how it is working and oringially it was intended for windows 98, but besides this exit issue, everything works fine. During exit it stops several open threads and closes communication so it should take some seconds for it to exit when you press the X button. If I press the abort button on this message box the program exit as it should. If I press the exit now button, it exit the program and it looks fine, but I think it doesn't stop the threads in the correct way. Anyway it has never been any issue really, more than it's annoying.
Is there a way to disable this "feature" with the program not responding message or set the timout to something higher than the 2-3 seconds it seems to be at right now?

closed account (Dy7SLyTq)
is it hitting an infinite loop or passing bad data and cant recover
No not really, it take some time to close down some threads and close communication, so if you just leave the "program not responding" window open it will close as it should, so it's more a "visual" problem that it looks bad to have that not responding window shown and also if you press the stop immediately button, I guess the program doesn't exit as it should.
Just don't block the main thread while waiting.
+1 @ modoran.

Windows thinks a program is "not responding" when it doesn't process messages. So just keep processing (or discarding) windows messages while you wait for the child threads to shut down.
It's not so easy to do this since everything is handled with different threads. There are not a "main loop" and I can't really see anythere it hangs. As soon as I press the X button, it jumps to a "closeHandle" routine and at the same time or within a second I get the program not responding message.
If I remove the close handle routine, when it just shut down without waiting for anything so that works, but I'm not sure it's the best way. If it closes all the created threads and so?
Is this a windows program or a console program?

If it's a windows program, Windows will send a WM_QUIT message to the parent window when the program is shutting down. Just intercept that message in the main window's message handler and signal for all other threads to shut down.

Then, simply don't exit that main window's message pump loop until you get confirmation that all threads have shut down.


The message pump loop is the key area of code here.
It is a console program. It doesn't do anything visual or so, just handles some serial communication between different other program (who are windows programs)
Can't you port the code in the console program to be contained inside your Windows program? Shouldn't be difficult, after all they are both written in the same language? Even if the console program is written in C it won't be difficult to port.
Topic archived. No new replies allowed.