Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
OnNavigationCompletedHex firing

I'm new in Antview, testing for deciding to buy.
We use VFP

.- Wrote in code just a mess in OnNavigationCompletedHex event. Fine. It works. (after setting EventsUseHexadecimal = true)
.- Then, instead of show a message, modify a form property to know when url finished
     thisform.terminado = .t. && (true)
.- In the launch code, i use a loop (really easy to understand):
     thisform.terminado = .f.
     do while !thisform.terminado
          wait window "Waiting page to finish load..." timeout 0.5 && half a second

.- Incredibly, thisform.terminado property never change his value; OnNavigationCompletedHex does not fire.

Any idea?
Thanks in advance

discovered that, no matter what code is after navigate method makes OnNavigationCompletedHex no firing.
Is only fired if there is no code after.

Thank you for your question.

Almost all of the methods in WebView2 (the control from Microsoft that AntView provides access to) are asynchronous in nature.
That means that trying to approach problems in a synchronous way do tend to be problematic.
It's not that you are the first to ask these kind of questions, in fact Microsoft gets this question pretty regularly over at github.

See for example:
So you’re certainly not alone in wanting this kind of support.

You might be able to get what you want by pumping the message queue, but it is not ideal and should only be considered a workaround. Not sure what "doevents" in VFP does under the hood, if it actually pumps the message queue or not.

Personally I also prefer to write the code in a synchronous way, but it is not what Microsoft gave us, so we'll have to do with what we have. Their reasoning is that "everything on the web is asynchronous by nature" and they have a point.

One way I worked around these kind of issues in similar languages was by instead of using the doevents type of solution is to start a windows timer that checks the property.
Then when that property changes trigger the method that handles the rest of the logic.

An example of that is written out for a PowerBuilder example here:

If you can't use a timer, then an alternative solution would be to move the logic where you handle the navigation itself in the OnNavigationCompletedHex event?
The NavigationIdHex can be used to identify which URL you are processing (You can link NavigationIdHex and URL via the OnNavigationStarting event)

FWIW, I will experiment a bit and see how hard it is to also provide a synchronous version of the Navigate method. I can see how having that might simplify things by a lot.

Hope this helps,

Forum Jump:

Users browsing this thread: 1 Guest(s)