I am fixing a GUI application programmed with MFC. To run a communication stack a new thread is created. On some events I want to stop this but I know that only in the worker thread and I cannot get the correct behaviour from stopping the worker thread from itself. So I need to send a message to the main thread and tell it to stop the worker thread so that the main thread can then take the correct action.
I am unsure how to do this. I have looked at the SendMessage function in CWnd but it does not take threadid as an argument and I dont get what I need to include to use http://msdn.microsoft.com/en-us/library/windows/desktop/ms644944(v=vs.85).aspx.
SendMessage
/PostMessage
with a custom message (WM_APP + x
) you can pass anything you like as theWPARAM
andLPARAM
. The system will not interpret the message for you in any way but will simply pass the parameters you provide to your message handler. – IInspectable