Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

STA reentrancy nightmare

0 views
Skip to first unread message

András Lukács

unread,
Feb 28, 2008, 12:50:37 PM2/28/08
to
Hi, All,

I have a COM object (ClientObj) in an STA of a client application, which
accesses an object (ServObj) in the MTA of an out-of-process server.

Whenever ClientObj calls a method of ServObj, the COM message pump will
call methods of ClientObj before the ServObj method returns. I know this
is normal for STAs.

Some of the methods of ServObj call back methods of ClientObj, so I need
reentrance in these cases, but not in others.

I.) So I wonder whether I could use an IMessageFilter implementation
registered on the STA of the client in a way that it should deny
CALLTYPE_TOPLEVEL_CALLPENDING calls. This way, no new calls from outside
the STA would be able to enter until the call to any method of ServObj
has finished (or so I think).

II.) A related dilemma of mine is what exactly the dwCallType parameter
of IMessageFilter.HandleIncomingCall() means when its value is
CALLTYPE_NESTED. This is the (fuzzy) explanation on MSDN:

CALLTYPE_NESTED: "A call has arrived bearing the same logical thread
identifier as that of a previous outgoing call for which the object is
still awaiting a reply. Calls of this type should always be handled."

Which of the following does that mean?
A) the incoming call wants to run on the same thread on which there
is an ongoing call to a ServObj method
B) the incoming call is arriving from the same thread on which an
ongoing call to a particular method of ServObj is being executed

I can only hope that it's not option A) because that would not help me
in any way in an STA, since all the incoming COM calls would want to run
on its single thread. I also have the same interpretative problem with
CALLTYPE_TOPLEVEL_CALLPENDING.

I'd be happy with any clarification and/or pointers!
Thanks in advance,

András

0 new messages