Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
navigatetostringsync problem
#8
(2026-03-17, 11:36:08)carlos@agpsoftware.com Wrote: You are right:
Event OnwebMessagereceived calls a method 'generar_pdf' that calls to cargar_editor method.
Don't know other way to do it: i have to wait for a script that returns me some data and then fire code that creates a pdf file with this data.

OK.
The idea behind the "Sync" methods is that it allows you to write code in a more procedural matter whereas the WebView2 control itself is completely event based. Mixing event based code and these "Sync" methods is currently not supported. 

The solution here is to use the asynchronous alternative NavigateToString method instead.
But as you say "you have to wait".. the solution to that is to use OnNavigationStarting event to get the NavigationIdHex value via the Args parameter. You can check the Uri and RequestHeaders to verify that this is the correct URL to check.
Then in OnNavigationCompletedHex you can wait for the event with the correct NavigationId to trigger.
That would be the technically correct way.

Alternatively instead of trying to track the NavigationId, you probably also can keep a global boolean to set just before and keep track of "NavigateToString triggered" and then wait for OnNavigationCompletedHex to trigger, do what you need to do and reset the global boolean back to false.
--
Wil
Reply


Messages In This Thread
RE: navigatetostringsync problem - by wila - 2026-03-16, 12:06:23
RE: navigatetostringsync problem - by wila - 2026-03-16, 22:28:25
RE: navigatetostringsync problem - by wila - 2026-03-17, 10:30:02
RE: navigatetostringsync problem - by wila - 2026-03-17, 12:02:03
RE: navigatetostringsync problem - by wila - 2026-03-19, 08:55:23

Forum Jump:


Users browsing this thread: 1 Guest(s)