Tuesday, June 21, 2011

Synchronous WebBrowser control navigating

For the random people that stumble upon this blog, this article relates to the .NET framework's "WebBrowser" class which basically allows a programmer to use internet explorer within his application.  In fact, you can create 10 instances of IE and programmatically make them perform a task, if you want to.
http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.aspx

This is some high-level goodness provided by programming languages like C# and Visual Basic, aka the butter-knife of programming languages.  You might enjoy this humerous photo:


Often times subscribing to an event just isn't synchronous enough, one common case is navigating to a web page using the WebBrowser control.

To make it behave synchronously, this snippet is of use:


this.webBrowser.Navigate(url);
while (this.webBrowser.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}

6 comments:

  1. Thats kind of neat. Sadly i don't know what any of it means.

    ReplyDelete
  2. Nice pictorial representation of the tools of the trade :) C++ looks like the ultimate winner, but you gotta have some super-human agility to use it to its full extent.

    ReplyDelete
  3. Good shit.

    Hahaha Java/C#, butterknife.

    ReplyDelete