Pergunta

I need to prevent WebBrowser.Navigate() run on the same thread because I need the process to be certain order.

I came across Async/Await implementation of WebBrowser class for .NET which uses async/await implementation but I have to use .net 3.5 which doesn't support it.

Anyone know of any alternative methods?

Foi útil?

Solução 2

I ended up setting a flag on the main form. Then there is a thread.sleep until the flag is reset.

Outras dicas

As far as I understand your requirements, you can use the WebBrowser component's DocumentCompleted event in the following way:

webBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(Loaded);
webBrowser.Navigate(...);

...

void Loaded(object sender, WebBrowserDocumentCompletedEventArgs e)
{
    // do stuff that needs to be run after the page is loaded
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top