I am having problem with the chromiumbrowser right now. It's causing me a headache, because it is such a little problem but I can't find a way out of it.
I am using VB.NET with Visual Studio 2017 and the version of CefSharp is 57.0.0
I have successfully imported cefsharp into my project and did all the necessary stuff.
The problem is that
- Code: Select all
.Load()
Explanation of the problem: I have 2 buttons, "btn1" has this piece of code:
- Code: Select all
Private Sub btn1_Click(sender As Object, e As EventArgs) Handles btn1.Click
chrome.Load("http://whatsmyuseragent.com/")
endThread = True
End Sub
"btn2" piece of code:
- Code: Select all
Private signupURL As String = "someurl.com"
Private Sub btn2_Click(sender As Object, e As EventArgs) Handles btn2.Click
If waitForPageLoad(signupURL) = False Then
GoTo EndThread
End If
'More code goes here, but it doesn't have to do anything with this problem.
End Sub
Private Function waitForPageLoad(url As String) As Boolean
For i As Integer = 0 To 1 Step 1
chrome.Load(url)
chrome.Reload(False)
isPageLoaded = False
checkForPageLoad()
If isPageLoaded = True Then
If chrome.GetBrowser.IsLoading = False And chrome.GetBrowser.HasDocument = True Then
If curURL = url Then
Return True
End If
End If
End If
addItemToActions("Retrying to load page...", Color.Tomato)
Next
Return False
End Function
This is how I check if page is loaded:
- Code: Select all
Private Sub loadStateChanged(sender As Object, args As LoadingStateChangedEventArgs)
If args.IsLoading = False Then
isPageLoaded = True
End If
End Sub
Private Sub checkForPageLoad()
Dim sec_left As Integer = My.Settings.ConTimeout
For i As Integer = 0 To sec_left - 1 Step 1
If isPageLoaded = True Then
Exit For
End If
Thread.Sleep(1000)
Next
End Sub
Now what's the problem?
If I click on btn2 it loads "signupURL" page with no problems whatsoever. Even If I click repeatedly on btn2 it still works.
If I click on btn1 it loads url I specified above no problem as well.
But now, after I've clicked on btn1 and the page "http://whatsmyuseragent.com/" is loaded, If I click btn2 it just reloads "whatismyuseragent" page. It doesn't Load signupURL at all.
Output I get inside my listview when I run this:
- "Retrying to load page..."
"Retrying to load page..."
"Thread stopped"
Why does this happen???