Stopping a UI thread
C / C++ / MFC
1
Posts
1
Posters
0
Views
1
Watching
-
I have a UI thread that works but I'm trying to figure out how to reliably stop the thread. The OnIdle function in the thread periodically calls WaitForSingleObject on a particular event, if it's set, it calls PostQuitMessage that we are quitting and then returns 0 to signal it doesn't need to run anymore. Half of the time this thread and the main one deadlock, sometimes I get some CResourceException and I don't trust it to stop the thread cleanly. I've read plenty on how to terminate the thread but it feels like it's not enough and doesn't always work. Does anyone have any pointers or a good way to stop the thread cleanly from outside of the thread?