Using VB.NET Framework 3.5 and Visual Studio 2005 i crated a project which uses the WebBrowser object in a working thrat. Breaking it down to the very basics, it looks like:
Dim bWbCompletedDocument As Boolean = False
Sub WbCompletedDocument(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs)
bWbCompletedDocument = True
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)Handles Me.Load
Dim th As New System.Threading.Thread(AddressOf worker)
Dim Wb As New WebBrowser
Wb.ScriptErrorsSuppressed = True
AddHandler Wb.DocumentCompleted, AddressOf WbCompletedDocument
Dim start As Date = Now
Do While start.AddSeconds(20) > Now
If (bWbCompletedDocument = True) And (Wb.IsBusy = False) And (Wb.ReadyState = WebBrowserReadyState.Complete) Then
If bWbCompletedDocument = False Then
'more code here
There is no GUI of the Browser but everything works fine. I navigate to a page catch the DocumentCompleted-event, check the ReadyState and if he IsBuisy and go on with my code.
WebBrowser-Object and/or to wait for it to finish?