I ended up setting a flag on the main form. Then there is a thread.sleep until the flag is reset.
WebBrowser run on same thread
-
09-07-2023 - |
Question
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?
Solution 2
OTHER TIPS
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
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow