Dave's Brain

Browse - programming tips - win32 msg to thread

Title: Win32: Messages to threads
Date: 1997dec15

Q. Up until now I was using Mutexs and Semaphores to communicate
with my thread.  But what if you want to queue some messages?

A. PostThreadMessage() ... I wish I'd known about it before
so I though I'd tell you about it. The thread needs to have a
PeekMessage() loop.

Here's what the manual says:

The PostThreadMessage function places (posts) a message in the message queue of the
specified thread and then returns without waiting for the thread to process the message. 

BOOL PostThreadMessage(
DWORD idThread, // thread identifier
UINT Msg, // message to post (nearly always WM_USER - dave)
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
); 

Add a comment

Sign in to add a comment
Copyright © 2008, dave - Code on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License.