Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If the interface in your question is a COM interface, the approach given by Quassnoi might not be sufficient. You have to pay attention to the threading-model of the COM object in use. If the secondary thread will join a separate COM apartment from the one that your COM object was created in, and if that object is not <em>apartment-agile</em>, you'll need to marshal that interface pointer so that the secondary thread gets a proxy, and not a direct pointer to the object.</p> <p>A COM object is normally made apartment-agile by using a special implementation of IMarshal. The simplest approach is to aggregate the Free Threaded Marshaler.</p> <p>Some useful links...</p> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/ms693316.aspx" rel="nofollow noreferrer">CoMarshalInterThreadInterfaceInStream</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/ms693729(VS.85).aspx" rel="nofollow noreferrer">GlobalInterfaceTable (GIT)</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/ms694500.aspx" rel="nofollow noreferrer">CoCreateFreeThreadedMarshaler</a></li> </ul> <p>Update: About the Free-threaded Marshaler...</p> <p>It's clear from comments on this topic that some people would recommend that you never touch the FTM. While "Effective COM" is an excellent book, I think some of its recommendations are open to interpretation. Item 33 says "Beware the FTM"; it does not say "Never use the FTM". Very wisely it advises caution particularly when your apartment-agile object holds references to other objects, because they might not be apartment-agile. So really the advice is: think carefully when building apartment-agile objects, whether or not they use the FTM to achieve their agility. If you're sure you can build an apartment-agile object, I see no reason why you wouldn't use the FTM to achieve that.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload