I'm trying to set up a situation where outside of a form I can have form1.webbrowser1 start at www.google.com and navigate to www.yahoo.com where the URL before the navigate is www.google.com and after the navigate is www.yahoo.com.
This will navigate the webbrowser from another thread using this code on form1:Code:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim testthread As New System.Threading.Thread(AddressOf Form1.dowork) site1 = "www.yahoo.com" Debug.Print(Form1.WebBrowser1.Url.ToString) 'this shows www.google.com testthread.Start() System.Threading.Thread.Sleep(3000) 'System.Windows.Forms.Application.DoEvents() System.Threading.Thread.Sleep(3000) Debug.Print(Form1.WebBrowser1.Url.ToString) 'this shows www.google.com End Sub
Code:Public Delegate Sub navigatecallback() Public Sub navigate() If Me.WebBrowser1.InvokeRequired Then Me.WebBrowser1.Invoke(New navigatecallback(AddressOf navigate)) Else Me.WebBrowser1.Navigate(site1) End If End Sub Public Sub dowork() navigate() End Sub
Why is is that, when I step through this, my navigating thread does not start when i testthread.start()?




Reply With Quote