Click to See Complete Forum and Search --> : COM message pump


George2
March 27th, 2008, 04:18 AM
Hello everyone,


Two questions about message pump in COM STA.

1. The term "message pump", means message queue? Pushing message into the message queue? Or retrieve message from the message queue?

2. What is the impact if the message pump is not alive in STA? It will block method invocation from other apartment?


thanks in advance,
George

Igor Vartanov
March 27th, 2008, 06:56 PM
1. Retrieving.
Pushing belongs the system. That is what it does on PostMessage calls and other aspects like processing hardware events (keyboard, mouse, device notifications, etc.) and other stuff like painting or else.

2. A stuck message pump prevents STA interfaces from normal processing - the calls appear blocked. In his Inside COM Dale Rogerson warns you about that. Kinda obvious thing, I dare say. ;) Why?

George2
March 28th, 2008, 01:07 AM
Thanks Igor,


I do not understand why caller will be blocked, since caller will use PostMessage, PostMessage is asynchronous call (compared with SendMessage, synchronous call)?

1. Retrieving.
Pushing belongs the system. That is what it does on PostMessage calls and other aspects like processing hardware events (keyboard, mouse, device notifications, etc.) and other stuff like painting or else.

2. A stuck message pump prevents STA interfaces from normal processing - the calls appear blocked. In his Inside COM Dale Rogerson warns you about that. Kinda obvious thing, I dare say. ;) Why?


regards,
George

Igor Vartanov
March 28th, 2008, 07:11 AM
I never told you that COM client will use PostMessage, it's only your imagination did. ;)
The client calls an interface method and remains blocked until method returns, pretty much the same as in any function call. What method - send or post - will be used by COM runtime? I don't care. May the COM hidden window message loop be blocked? Of course it's probable, but I don't care why, because it's supposed that following precise instructions will always work for me. And it really did all the time!

When you refill the car's tank, you may come to idea to fill it with sugar syrup or sulphuric acid. But you never will, I believe, because you follow the precise instruction of which type of fuel belongs your car engine much better, and sugar syrup is not in the list, I'm sure of that for hundred percent.

Now the precise COM instruction states: in your interface implementation return from method call as fast as you can to not block callers. Period. About whys please refer to Rogerson and Box books. Those guys are really the best in explaining.

George2
March 28th, 2008, 10:04 AM
Thanks Igor,


Question answered.

I never told you that COM client will use PostMessage, it's only your imagination did. ;)
The client calls an interface method and remains blocked until method returns, pretty much the same as in any function call. What method - send or post - will be used by COM runtime? I don't care. May the COM hidden window message loop be blocked? Of course it's probable, but I don't care why, because it's supposed that following precise instructions will always work for me. And it really did all the time!

When you refill the car's tank, you may come to idea to fill it with sugar syrup or sulphuric acid. But you never will, I believe, because you follow the precise instruction of which type of fuel belongs your car engine much better, and sugar syrup is not in the list, I'm sure of that for hundred percent.

Now the precise COM instruction states: in your interface implementation return from method call as fast as you can to not block callers. Period. About whys please refer to Rogerson and Box books. Those guys are really the best in explaining.


regards,
George