Hey I have a program that has a webBrowser navigate through a few pages, and when it gets to the last page I set it to navigate to, checks if there is a certain string on that page. I just switched my code around to use multithreading and now the statement
If WebBrowser1.DocmentText.Contains("...") Then
...
End If
generates an InvalidCastException that says "Specified Cast is Not Valid". Anybody have an idea of why this might be happening.
Here is how I start the thread (when a button is clicked)
FUBCThread.Start()
And here is the Sub that is run
Public Sub beginFUBC()
While True
If TimeOfDay > "11:31:00 PM" Or TimeOfDay < "07:00:00 AM" Then
Else
WebBrowser1.Navigate(...)
Delay(10)
WebBrowser1.Navigate(...)
Delay(5)
WebBrowser1.Navigate(...)
Delay(5)
WebBrowser1.Navigate(...)
Delay(5)
WebBrowser1.Navigate(...)
Delay(5)
Try
If WebBrowser1.DocumentText.Contains("...") Then
SendSMTP()
Exit Sub
End If
Catch x As Exception
MessageBox.Show(x.Message)
End Try
End If
Dim time As Integer = Convert.ToInt32(timeBox.Text)
Threading.Thread.Sleep((time * 60) * 1000) 'Sleeps for however many minutes specified in the time box minutes and then tries again
End While
End Sub