MFC Application is not closing completely
Posted on 2009-07-09
I have inherited an application that under repeatable circumstances the program will not close completely when closing with the "red X". All windows close, but the application is still running. When paused in debug mode, it appears that the main thread is continuing to process the message loop, although the PeekMessage() function that the loop calls consistently returns a NULL message.
The same circumstances were previously causing an exception due to an attempted access of deallocated structures. After modifying the code to prevent those accesses, the current situation appeared.
To give a basic idea of what is happening in the code under these circumstances:
-The application uses the MDI structure and the issues appears when closing the application with one of the views open.
-Upon initialization of this view, a timer is set to communicate with a device periodically.
- When the user closes the program, the class calls a function to shut down the timer and the communication port. All of this seems to complete successfully, except for the fact that the application is still running.
Thank you for any help you may offer.