title: ATL sample of calling (marshalling) Apartment-threaded COM interfaces from a worker thread
body: <p>I'm looking for a code sample which illustrates making cross-threaded COM calls in an ATL COM Server DLL.  Know one?</p>
  
  <p>More details:</p>
  
  <p>My component is an IE Browser Helper Object which needs to do work on a background thread. In one of my object's methods called from IE's main thread, IE gives me a pointer to the IE DOM (<a href="http://msdn.microsoft.com/en-us/library/aa741505%28v=vs.85%29.aspx" rel="nofollow noreferrer"><code>IHtmlWindow2</code></a>) and I store it in a local member variable.</p>
  
  <p>Now I want to create a worker thread which can asynchronously call methods on that COM interface pointer that I've just stored.</p>
  
  <p>If it matters, my calls will happen after I return from the method where I got the interface pointer from IE, so IE (and not my code) will have control when I try to make the calls from my worker thread.  </p>
  
  <p>Both my component and the host application are Apartment threaded. </p>
  
  <p>Anyone know a good C++ sample showing how this is done?</p>
  
  <p><em>I'm specifically looking for a short, straightforward sample (and <strong>not</strong> just a pointer to relevant documentation) because I read <a href="https://stackoverflow.com/questions/1612759/what-is-the-preferred-method-of-marshalling-com-interfaces-across-threads">this question</a> and its answers and got intimidated at the amount of learning I'd have to do to write an implementation from scratch. Any time someone recommends to read a Don Box book before writing code, you know you're in for a long, confusing night... :-)</em></p>