Ben Voigt [C++ MVP] wrote:
The original post asked about SendMessage and PostMessage as a means of
communication. Which to my small little brain means "between threads",
because I'd have used a direct function call in native code as well if that
was what I wanted.
I don't disagree with that application. But I do think that's an overly
narrow interpretation of "communication". As I mentioned to the OP, the
problem description, such as it was, was very vague and it's very
difficult to answer vague questions like that in a really useful way.
But I would not limit "communication" to be inter-thread communication.
I would say that sending messages like WM_SETTEXT, EM_REPLACESEL, etc.
are forms of communication, and they often occur in a single thread.
Likewise, something like WSAASyncSelect() that uses window messages to
handle Winsock communications; again, usually all in the same thread.
I also think that while direct function calls are best where possible,
there are viable means of inter-thread communication that don't use
Send/Post/Invoke/etc. as the mechanism.
I have tried to encourage the OP to clarify what it is exactly he's
trying to replicate in .NET. With better details, it's a lot easier to
provide a useful reply. And it may well be that using Control.Invoke()
or Control.BeginInvoke() are in fact the things he's looking for. But
those apply to very specific needs, and it could just as easily be that
he doesn't need those at all.
Pete