how can I set a timeout using the webBrowser.
I know this has been asked many times and for what I see any version of visual studio has the same problem: a webbrowser with no timeout. What happens when a site blocks the whole process?
it's a problem! I've tried datediff, timer... but impossible!
Private dt As DateTime
Private dt2 As DateTime
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
WebBrowser1.Navigate("http://www.gabriels.be/")
dt = Now
While Not WebBrowser1.ReadyState = WebBrowserReadyState.Complete
dt2 = Now
Text = DateDiff(DateInterval.Second, dt2, dt)
If DateDiff(DateInterval.Second, dt2, dt) = 6 Then
Exit While
End If
Application.DoEvents()
End While
MsgBox("salut")
End Sub
Thank you
UPDATE:
Private Sub ButtonTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonTest.Click
Dim url As String = ""
url = "http://www.gabriels.be/contact"
NavigateTo(New Uri(url))
MsgBox("stop")
url = "http://www.google.es/"
NavigateTo(New Uri(url))
MsgBox("end")
End Sub
Public Sub NavigateTo(ByVal url As Uri)
Timer1_html3.Enabled = True
WebBrowser1.Navigate(url)
While Not WebBrowser1.ReadyState = WebBrowserReadyState.Complete
Application.DoEvents()
End While
End Sub
Private Sub Timer1_html3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1_html3.Tick
Timer1_html3.Enabled = False
MessageBox.Show("Timeout on navigation")
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
If e.Url = WebBrowser1.Url And Timer1_html3.Enabled Then
Timer1_html3.Enabled = False
End If
End Sub
It's blocked. the webpage shows itself but I don't see the stop message of the tick event. why is that ?