Search code examples
multithreadingcombho

COM: calling from other thread causes crashes, how to make it run on the same thread?


I am doing a BHO (extension for IE) that receives events on other thread. When I access the DOM from that other thread, IE crashes. Is it possible to make the DOM accessed from the same thread as the main BHO thread so that it does not crash?

It seems like a general COM multithreading problem, which I don't understand much.


Solution

  • Look into using CoMarshalInterface or CoMarshalInterThreadInterfaceInStream

    These will give you a wrapped interface to an STA COM object that is thread safe.