Welcome Guest Search | Active Topics | Sign In | Register

EO.Browser disrupts program flow Options
janders
Posted: Monday, May 25, 2015 6:25:22 PM
Rank: Newbie
Groups: Member

Joined: 5/25/2015
Posts: 3
I have a functional application using one of your competitor's web browser components. Due to some changes in design/function requirements, I am evaluating your Web Browser component as a potential replacement.

I am finding that - when integrating EO coding into my working application - many (actually, all tried) EO methods and EO events seem to hang/stop established program flow.

Example:

in Load() I have essentially:

AddHandler wvEO.LoadCompleted, New NavigationTaskEventHandler(AddressOf wvEO_LoadCompleted) ' this does fire as expected
debug.print("loading home page")
wvEO.LoadUrlAndWait(INI.GetValue("L", "LA_URL")) ' INI returns the full/proper URL/URI, "https://www......."
debug.print("loaded")
timer1.enabled = true ' interval 500ms
debug.print("done")
end sub

Quite mysteriously, with EO code my timer never fires. The page loads and is rendered fully, the "loaded" debug message is displayed. Even "done" debug is displayed. But timer1 never fires - a breakpoint on the first executable line of timer1 code does not hit.

This type of behavior also occurs in the wvEO_LoadCompleted event. When I have the event enabled, the event does fire, but the simple routine never exits.


I noticed in some other forum posts that webview.doevents() is sometimes preferred over application.doevents(). Where I have used the "app" version, I have commented existing and/or replaced with webview.doevents() - however doevents is not used in the routines identified so far as "show-stoppers".

I have been trying to absorb the documentation, scouring forums, but I have not so far seen anything obviously relevant.

Hints?
eo_support
Posted: Monday, May 25, 2015 9:43:26 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Hi,

You should not call LoadUrlAndWait inside your Load event handler. The WebView will not be able to finish loading an Url unless it has been fully initialized. However it will not be fully initialized unless the parent form or window has been fully initialized --- which will only happen after the window/form's Load event has been fired. So calling LoadUrlAndWait unside your Load event would introudce a typical dead lock situation.

You can simply set the WebView's Url property in your Load event handler (or call LoadUrl instead of LoadUrlAndWait), and then rely on LoadCompleted event to find out when the page has been fully loaded. If your are loading a Url due to a user action, for example, inside a Button's Click event handler, then you can call LoadUrlAndWait without any issues.

Hope this helps. Please feel free to let us know if you still have any questions.

Thanks!
janders
Posted: Tuesday, May 26, 2015 7:46:16 AM
Rank: Newbie
Groups: Member

Joined: 5/25/2015
Posts: 3
Thank you. I have implemented your suggestions.

I have altered my load to now be essentially only this:

{pseudocode}
Sub Load()
Enable Timer
End Sub

The Timer does indeed fire!

The goal of the Timer code is to load the initial URL and allow the loading process to proceed and stabilize ultimately at the desired page with the specified TITLE {Timer pseudocode} :

Disable Timer
AddHandler for _LoadCompleted
Addhandler for _TitleChanged
webview.Url = {proper URL} ' NO WAIT THIS TIME
WaitForTitle("PAGETITLE", 3)


The handler does nothing more than update the variable:
Private Sub _TitleChanged(ByVal sender As Object, ByVal e As EventArgs)
eoCurrentTitle = webview.Title
End Sub

And the WaitForTitle only loops until until conditions are met:
Public Sub EO_WaitForTitle(ByVal _title As String, ByVal _WaitForSeconds As Integer)
Dim sw As New Stopwatch
sw.Start()
debug.print("Waiting...")
While eoCurrentTitle.IndexOf(_title) < 0 And sw.Elapsed.Seconds < _WaitForSeconds ' eoCurrentTitle from the TITLECHANGED event
' Application.DoEvents ()
WebView.DoEvents()
End While
sw.Stop()
MSGBOX("THIS MESSAGE WILL NEVER APPEAR")

End Sub

"Waiting..." is properly displayed. The MsgBox never executes however.

IF I comment both .DoEvents, then the msgbox is executed. With EITHER .DoEvents enabled, flow hangs.

Why are DoEvents causing this? And - MOST IMPORTANTLY - what section of documentation fully explains all of this so I may become self-reliant as I continue coding/evaluating?



eo_support
Posted: Tuesday, May 26, 2015 10:19:28 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Hi,

You need to work out this kind of problems yourself. What you have are basic generic programming issues, they are not related to EO.WebBrowser, and obviously it won't be covered in our documentation either.

When you say your "flow hangs". It's because your loop never exit. We are not in a position to tell you why a loop in your code does not exit. You need to debug that yourself. If however after debugging that code, you concluded that the problem originates from our side (for example, an event that should have been fired is not fired), then you can describe the problem to us and we will look further. So you will need to be able to reach the point where you can clearly tell us "I was expecting EO.WebBrowser to do this, but it did that" instead of "my flow hangs" in order for us to answer your question. As long as your question is directly related to our product, we will be able to either answer your question, or point you to the right documentation. There is no way our documentation will cover the kind of "flow hang" question you have right now since it's just generic programming question.

As an example, your previous "flow hang" question is because LoadUrlAndWait never returns. The fact "LoadUrlAndWait never returns" is a question directly related to our product, but "flow hang" is not. As a general guideline, we won't debug your code. So you must be able to analyze your own code in order to reach from what's wrong with your application to what's wrong with our product first.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.