Sign in to follow this  
fathom88

Win App Not Waiting For Thread To End??

Recommended Posts

I'm writing a Win MFC app in VC++. I have several threads which run in the background. The threads close out when I send a cmd to stop them called StopAllThreads(). I wait for the threads to exit. However, I have a problem when I exit out and make the same call. Windows closes the my app's window just fine. However, I can still see the app is running when I bring up task manager. I don't think Windows is waiting for my threads to end. One of my threads takes some time to end because it's doing a periodic socket "Connect" when the server down to try and re-estab a connection. I could be calling the StopAllThreads() func in the wrong place. Should I have my Doc class respond to the ShutDown message by making the call to StopAllThreads()? Thanks in advance.

Share this post


Link to post
Share on other sites
I'm not sure I understand the problem. If your task is still running, then at least one thread is still alive, regardless of whether or not any window is visible. Closing a window doesn't necessarily have any relationship to running threads.

What exactly does StopAllThreads do? How does it signal each thread to stop? How does each thread stop? Have you tried having each thread open a log file and record when it was started and when it was stopped, to isolate which thread is remaining alive and what it is doing?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this