I want to know if there are anyway to run the actions of a webbrowser behind the scene without freezing the main UI? I want to be doing other stuff on the main UI and have the webbrowser do stuff behind the scene from an button event. Any way to do this? I've looked into background worker but don't seem to be working with webbrowser coms ect. Here's what I've tried but keeps freezing/lagging on wait for webpage to load:
Private Property pageready As Boolean = False
Public Sub WaitForPageLoad()
AddHandler WebBrowser1.DocumentCompleted, New WebBrowserDocumentCompletedEventHandler(AddressOf PageWaiter)
While Not pageready
Application.DoEvents()
End While
pageready = False
End Sub
Public Sub PageWaiter(ByVal sender As Object, ByVal e As WebBrowserDocumentCompletedEventArgs)
If WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
pageready = True
RemoveHandler WebBrowser1.DocumentCompleted, New WebBrowserDocumentCompletedEventHandler(AddressOf PageWaiter)
End If
End Sub
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Try
WebBrowser1.Navigate("http://www.mypage.com")
WaitForPageLoad() >>>> Lags and freezes UI for a sec or two to wait for page loading. How can i do this in the background?
Catch ex As Exception
End Try
End Sub
Private Sub BackgroundWorker1_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
'Here i will get my attributes off the webpage ect....
End Sub