Click here to Skip to main content
15,895,142 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralCOM message pump Pin
George_George26-Mar-08 22:18
George_George26-Mar-08 22:18 
GeneralRe: COM message pump Pin
Iain Clarke, Warrior Programmer26-Mar-08 23:09
Iain Clarke, Warrior Programmer26-Mar-08 23:09 
GeneralRe: COM message pump Pin
George_George26-Mar-08 23:43
George_George26-Mar-08 23:43 
AnswerRe: COM message pump Pin
Roger Stoltz27-Mar-08 0:51
Roger Stoltz27-Mar-08 0:51 
GeneralRe: COM message pump Pin
George_George27-Mar-08 2:12
George_George27-Mar-08 2:12 
GeneralRe: COM message pump Pin
Roger Stoltz27-Mar-08 2:38
Roger Stoltz27-Mar-08 2:38 
GeneralRe: COM message pump Pin
George_George27-Mar-08 3:20
George_George27-Mar-08 3:20 
AnswerRe: COM message pump Pin
Roger Stoltz27-Mar-08 22:47
Roger Stoltz27-Mar-08 22:47 
Well, in a technical detail calls between apartments may, or may not, use ::SendMessage(). Whether it's an actual ::SendMessage() or ::PostMessage() call doesn't matter and is irrelevant.
The behaviour from the client point of view is the same; it works as if you've used ::SendMessage().

This is my point:
You asked if the call would block and the answer to that is simply 'yes'.
The RPC runtime will actually use ::PostMessage() to place a COM message in the message queue of the server, BUT the proxy will wait for the answer until the server responds.
This can be read in e.g. "Essential COM" by Don Box, chapter 5. If you have a MSDN Library (2005) installation you will also find this chapter as a book excerpt below "Win32 and COM Development". However, I was unable to find it at MSDN online.
Keep in mind that the server and client may not be located on the same machine which would make it impossible to use communication between the server and the client based on window messages. The network has to be involved.
But even if the network is involved, the same rules apply; the call from the client will block and the server must have a message loop that's not deadlocked.

According to my experience it seems to help programmers starting with COM calls crossing apartment boundaries to think of the call as if the message was sent using ::SendMessage(). The reason to even bring that up is that even a beginner have to know that an apartment exposing interfaces must have a message loop. It also assumes that the programmer is familiar with the problems using ::SendMessage(). If the COM beginner is told from the start that ::PostMessage() is used, chances are that he/she would believe that the call somehow would not block.

Regarding why the call is blocking, the simple reason is that each COM interface call must return a HRESULT and the result is unknown until the call has been serviced. For lengthy operations the server should, and usually would, use a callback interface to inform the client about the progress of the asynchronous operation. But this is asynchronous and non-blocking at a higher level.

If you still have question, please explain what you're trying to do that make you ask these questions.


"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown


GeneralRe: COM message pump Pin
George_George27-Mar-08 23:38
George_George27-Mar-08 23:38 
GeneralRe: COM message pump Pin
Roger Stoltz28-Mar-08 0:04
Roger Stoltz28-Mar-08 0:04 
GeneralRe: COM message pump Pin
George_George28-Mar-08 0:29
George_George28-Mar-08 0:29 
GeneralRe: COM message pump Pin
Roger Stoltz28-Mar-08 0:53
Roger Stoltz28-Mar-08 0:53 
GeneralRe: COM message pump Pin
George_George28-Mar-08 4:24
George_George28-Mar-08 4:24 
GeneralRe: COM message pump Pin
Roger Stoltz28-Mar-08 4:41
Roger Stoltz28-Mar-08 4:41 
GeneralRe: COM message pump Pin
George_George28-Mar-08 5:05
George_George28-Mar-08 5:05 
GeneralRe: COM message pump Pin
Stephen Hewitt27-Mar-08 15:33
Stephen Hewitt27-Mar-08 15:33 
GeneralRe: COM message pump Pin
Iain Clarke, Warrior Programmer27-Mar-08 22:49
Iain Clarke, Warrior Programmer27-Mar-08 22:49 
GeneralRe: COM message pump Pin
George_George27-Mar-08 23:48
George_George27-Mar-08 23:48 
GeneralProblem in Focusing... Pin
Ashish Chauhan26-Mar-08 21:16
Ashish Chauhan26-Mar-08 21:16 
GeneralRe: Problem in Focusing... Pin
Naveen26-Mar-08 21:49
Naveen26-Mar-08 21:49 
GeneralRe: Problem in Focusing... Pin
Ashish Chauhan26-Mar-08 22:42
Ashish Chauhan26-Mar-08 22:42 
GeneralRe: Problem in Focusing... Pin
Naveen26-Mar-08 22:49
Naveen26-Mar-08 22:49 
GeneralRe: Problem in Focusing... Pin
Ashish Chauhan26-Mar-08 22:57
Ashish Chauhan26-Mar-08 22:57 
GeneralRe: Problem in Focusing... Pin
Naveen26-Mar-08 23:12
Naveen26-Mar-08 23:12 
GeneralRe: Problem in Focusing... Pin
Ashish Chauhan26-Mar-08 23:24
Ashish Chauhan26-Mar-08 23:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.