|
-
May 28th, 2009, 02:34 AM
#1
Marshalling an interface pointer to multiple worker threads
I have an in-proc COM server object running in an NTA. This COM object creates multiple threads to call one of its methods in parallel to improve performance (oringinally the method was called multiple times synchronously). My worker threads all join an MTA via a call to CoInitialiseEx. One of the paramaters passed to the thread function is an interface pointer to the COM server. I know that I need to marshall the interface pointer, but do I need to marhsall it multiple times for each worker thread by calling CoMarshalInterThreadInterfaceInStream multiple times? And then in each worker thread, I can call CoUnMarshalInterThreadInterfaceInStream to unmarshall the pointer and then make the interface method calls. This way, each thread will use a separate IStream object. Is my understanding of marshalling correct? I thought that marshalling only took part between different apartments, not different threads (if in MTA), but I can't see how I can only marshall once for all the MTA worker threads as this will mean they will all use the same IStream object.
ALso, I have assumed that multiple threads can access the NTA COM server object concurrently, since the MTA threads will be calling it (the caller's thread is used to access objects in an NTA). It was created by another STA client, but I have assumed that the NTA is not fixed to the STA thread that created it - it can be directly accessed by threads of other apartments too.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|