Using WebView2 on a Non-UI Thread with a Dedicated Message Pump #4824
Unanswered
akguptakgp
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I’d like to run WebView2 on a thread that is not the UI thread, but I am implementing a dedicated message pump for processing WebView2 messages. Are there any downsides to this approach? I chose this method to ensure that WebView2 messages are processed promptly, as they can cause delays when handled on the UI thread.
Please note that the HWND being passed to CreateController is created in the UI thread.
I’ve tested this setup and haven’t encountered any issues so far, but I want to confirm if it’s a safe and reliable approach moving forward.
Reason for asking this is because in the "Threading model for WebView2 apps" webview2 article it is mentioned that it must be run in UI thread.
"
The WebView2 must be created on a UI thread that uses a message pump. All callbacks occur on that thread, and requests into the WebView2 must be done on that thread. It isn't safe to use the WebView2 from another thread.
"
Link to article https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/threading-model
Thanks in advance for your insights!
Beta Was this translation helpful? Give feedback.
All reactions