Q:

VB.NET AutoResetEvent

I am trying to learn more about event handling. I tried writing the code below but it doesn't seem to be working for some reason. What I am trying to do is navigating to a url, wait until its loaded and then run the msgbox. 
Any idea what I'm doing wrong?
Private Shared event_1 As New AutoResetEvent(False)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    WebBrowser1.Navigate("http://google.com")
    AddHandler WebBrowser1.DocumentCompleted, New WebBrowserDocumentCompletedEventHandler(AddressOf wb)

    event_1.WaitOne()

    MsgBox("The page is finished loading ")

End Sub

Private Sub wb(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs)
    If e.Url.AbsolutePath <> TryCast(sender, WebBrowser).Url.AbsolutePath Then
        Return
    End If
   event_1.Set()
End Sub

A:

You can just catch the DocumentCompleted event on the WebBrowser1 object like this:
Private Sub webBrowser1_DocumentCompleted(ByVal sender As Object, _
    ByVal e As WebBrowserDocumentCompletedEventArgs) _
    Handles webBrowser1.DocumentCompleted

    MsgBox("THe page is loaded")

End Sub

See samples here:
http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-2

