I am writing code with Visual Studio 2010 in VB.net with a WPF project. I have added references to MSHTML and SHDocvw as I am automating an Internet Explorer window. Note I am not hosting the webbrowser on a form. I am currently using the Shdocvw.InternetExplorer class to do this.
Irrespective of whether it is this class or another I assume my questions is a Managed Code / unmanaged code problem.
I am using WithEvents for my events. The problem is that I must use an STA thread to for example do anything with MSHTML but the events that come back from Internet Explorer are MTA threads. To work around this I have used a dispatcher, but this is not I think the best solution and I am thinking there must be a better way. This whole COM / Managed / Unmanaged code is a little bit hard to come to grips with as there are too many options.
So what is the correct way of dealing with the events raised?