Richard Andrew x64 wrote:I ask because I do not want the application to terminate when the secondary thread terminates. My understanding of the docs is that that could happen if I use a UI thread.
Could you show me what you are referring to? The only way that I am aware of... where a CWinThread can terminate the main thread is if you reach across threads to execute code. If a WM_QUIT arrives during that short period I believe it gets posted to the main threads message queue.
Don't do this:
Instead post a message WM_THREAD_A_DOSOMETHING
As long as ThreadA never touches ThreadB you shouldn't have any problems. Also don't create any windows or enter any modal modal loops from your CWinThread worker thread... do all window management from your main thread.
Follow these rules:
1.) Do all window creation in your main thread.
2.) Don't reach across threads to execute code.
3.) Use PostMessage to communicate between threads.
You *can* break these rules but make sure that you fully understand the consequences and how to get around them. Raymond Chen explains how you can get around messages are eaten by modal loops[^] here.