Tech Off Post

Single Post Permalink

View Thread: WPF + WindowsFormsHost + .Net Forms + ( COM interfaces + Forms Invoke ) = E_NOINTERFACE Exception
  • User profile image

    Dexter said:
    pompomJuice said:
    A correction:

    Control.Invoke does not spawn a new thread. Control.Invoke does some "magic" that causes the "invoked" code to execute on the thread that created the control (tipically the main thread).

    And a note:

    I'm not sure what was your solution after all. Creating a new thread every time you need to call into the COM component? That's scary! Smiley
    Aah thanks for informing me about the invoke mechanics. Thinking about it now, I realize I reduced it in my mind to "it spawnes another thread that can touch the UI", since when I encountered invokes I did not fully grasp that it was using delegates. Now I do. Still learning here Wink

    That was my solution yes. Reason being that there are thousands of lines of code. I cannot go change the structure of the program now so I need to handle this problem on a case by case basis. And that is, creating a new MTA thread and then returning the resulting work somehow. It worked, no exceptions, but clearly I broke something. And it was scary to do it that way. I don't like hacking.

    Thanks for the help.