Code:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim navthread1 As New System.Threading.Thread(AddressOf Module1.navigate) navthread1.Start("www.yahoo.com") System.Threading.Thread.Sleep(1) End Sub Public Delegate Sub navigatecallback(ByVal site As String) Public Sub navigate(ByVal site As String) Dim main As Form1 = CType(System.Windows.Forms.Application.OpenForms(0), Form1) If main.WebBrowser1.InvokeRequired Then main.WebBrowser1.Invoke(New navigatecallback(AddressOf navigate), site) Else main.WebBrowser1.Navigate(site) End If End Sub
When I step through it runs like there is no multithreading at all. module1.navigate does not even start until after the buttonclick event sub has ended. What is the difference between this code that i've posted and doing this?:
(other than this bottom code navigates the webbrowser BEFORE the button click sub has ended)
Am I doin something wrong with my navthread1 which prevents it from doing anything until after the button1 click sub has ended?
Code:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click form1.webbrowser1.navigate("www.yahoo.com") End Sub




Reply With Quote