Hi Everyone,
I am trying to migrate my app from CEF to the new Webview2 control.
I could manage to navigate to the desired html, load its javascript, register a PB user event, trigger the user event from Javascript and call EvaluateJavascriptAsync from PB. The only missing step for me is calling EvaluateJavascriptSync from PB (outside the registered event !), which actually immediately kills the IDE and the debugger.
Code like below seamlessly worked in CEF:
string js_command, js_result, js_error
int ret
ret = wb_1.EvaluateJavascriptSync('js_function("params");', ref js_result, ref js_error)
ret = wb_1.EvaluateJavascriptSync('javascript:js_function("params");', ref js_result, ref js_error)
At such places the async function works, but it would be much more convenient to use the sync one (e.g. for error checking).
Does any of you have gone through a similar exercise?
What are the constraints for using the sync function? Can you use it in the new control anyway?
Any help would be highly appreciated.
András Balázs
Thanks for your comment, but as I wrote I try to use the sync function outside the registered event.
András
You are right, it is easy to avoid the whole problem by moving the script to an object function of the window containing the web browser control and leave a POST in the event. However the same function works without problem in the navigationcompleted event of the control, and further to that you can freely use the Navigate function inside the registered event, which disturbs the picture a little bit.
Anyway It is far from being the end of the world, the rules of usage might be clearer in the documentation.
András