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

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.
     thisform.oAntView.object.navigate(MyUrl)
     do while !thisform.terminado
          doevents
          wait window "Waiting page to finish load..." timeout 0.5 && half a second
     enddo

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

Any idea?
Thanks in advance
Regards

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

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:
https://github.com/MicrosoftEdge/WebView...ssues/2117
And
https://github.com/MicrosoftEdge/WebView...ssues/1905
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:
https://doc.antview.dev/hs740.htm

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)

Edit:
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,
--
Wil
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)