Dilip
2006-07-19 16:49:11 UTC
I need to make a DCOM call from thread pool threads that were spun off
using QueueUserWorkItem. IOW, the callback function used by the thread
pool in console application 1 needs to call an interface method on a
COM object hosted in an out-of-proc COM server every now & then. This
out-of-proc server is completely free threaded (so no hairy STA related
issues).
my question is COM rules mandate that every thread that wants to make a
(D)COM call needs to call CoInitialize/CoUninitialize, right? Every
thread needs to enter an apartment before it can make a COM call, so
even if there is going to be only one MTA per process, a thread still
needs to enter it, right?
since I can't rely on the same thread pool thread executing my callback
function, do I need to call CoI/CoUni pair before every method call?
That somehow doesn't sound logical.
I was wondering if I could just create the said COM object as a global
object, let the main (primary) thread enter MTA using
COINIT_MULTITHREADED and let all those thread pool threads simply
access the global object. Will this create a problem exactly when I
demo it to my boss?
using QueueUserWorkItem. IOW, the callback function used by the thread
pool in console application 1 needs to call an interface method on a
COM object hosted in an out-of-proc COM server every now & then. This
out-of-proc server is completely free threaded (so no hairy STA related
issues).
my question is COM rules mandate that every thread that wants to make a
(D)COM call needs to call CoInitialize/CoUninitialize, right? Every
thread needs to enter an apartment before it can make a COM call, so
even if there is going to be only one MTA per process, a thread still
needs to enter it, right?
since I can't rely on the same thread pool thread executing my callback
function, do I need to call CoI/CoUni pair before every method call?
That somehow doesn't sound logical.
I was wondering if I could just create the said COM object as a global
object, let the main (primary) thread enter MTA using
COINIT_MULTITHREADED and let all those thread pool threads simply
access the global object. Will this create a problem exactly when I
demo it to my boss?