A background-thread can be configured to receive window messages. You would post messages to the thread using PostThreadMessage. What\'s the correct way to exit that message loo
Using PostThreadMessage
is not necessarily incorrect. Raymond's article that you linked to says:
Because the system tries not to inject a WM_QUIT message at a "bad time"; instead it waits for things to "settle down" before generating the WM_QUIT message, thereby reducing the chances that the program might be in the middle of a multi-step procedure triggered by a sequence of posted messages.
If the concerns outlined here do not apply to your message queue, then call PostThreadMessage
with WM_QUIT
and knock yourself out. Otherwise you'll need to create a special signal, i.e. a user-defined message, that allows you to call PostQuitMessage
from the thread.