In a C++ (MFC) app using WebView2
, I can't find a way to simply wait until the script passed to AddScriptToExecuteOnDocumentCreated()
is ready. My ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandler()
is just never called if I add some waiting code (e.g. WaitForSingleObject()
) after calling AddScriptToExecuteOnDocumentCreated()
.
Without the wait, the ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandler()
is reached and I can see it's invoked on the message thread. Then, obviously, if I have to make the UI (i.e. message thread) wait, it can't work.
Does someone know how we're supposed to use this properly?