Get ReadyState from WebBrowser control without DoEvents

Below is a basic WinForms app code, illustrating how to wait for the DocumentCompleted event asynchronously, using async/await. It navigates to multiple pages, one after another. Everything is taking place on the main UI thread. Instead of calling this.webBrowser.Navigate(url), it might be simulating a form button click, to trigger a POST-style navigation. The webBrowser.IsBusy async … Read more

Use of Application.DoEvents()

Hmya, the enduring mystique of DoEvents(). There’s been an enormous amount of backlash against it, but nobody ever really explains why it is “bad”. The same kind of wisdom as “don’t mutate a struct”. Erm, why does the runtime and the language supports mutating a struct if that’s so bad? Same reason: you shoot yourself … Read more