Re: threads/marshalling/callbacks
Jason S <jmsachs@gmail.com> wrote:
On May 3, 12:31 pm, "Igor Tandetnik" <itandet...@mvps.org> wrote:
Well, you more or less have the answer already. Your server needs two
threads: one to handle the stream of events, and the other to make
outgoing COM calls. The first thread does not need to be COM-aware;
communicate between the threads by some non-COM means (e.g. events or
window messages).
Hmm, something like that I had considered, but what I don't understand
is how a COM server can initiate outgoing COM calls unless those are
directly the result of an incoming COM call.
I'm confused. You have the interface pointer (passed to you in Advise).
What's stopping you from making a call on this poiner? What exactly
seems to be the problem?
Could you give me some more information on how to do this?
What, how to call a COM method? Like this:
pInterfacePointer->SomeMethod(someParams);
I have an EXE server with an apartment SA which handles incoming COM
calls, and has a few callback interface pointers p1, p2, p3.
The EXE server also has a worker thread SW which gets the fast events.
SW will set an Event HANDLE when it thinks that's appropriate.
(Exercise for the reader.)
How can I have a thread in apartment SA initiate an outgoing call
triggered on the Event HANDLE becoming set?
If you insist on using event handle, make your message pump based on
MsgWaitForMultipleObjects rather than GetMessage. I suggest you keep it
simple and just have the worker thread post a user-defined message to a
hidden window created by SA.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925