pub fn wait_with_pump<T>(rx: Receiver<T>) -> Result<T>
Expand description

The WebView2 threading model runs everything on the UI thread, including callbacks which it triggers with PostMessage, and we’re using this here because it’s waiting for some async operations in WebView2 to finish before starting the main message loop. As long as there are no pending results in rx, it will pump Window messages and check for a result after each message is dispatched.

GetMessage is a blocking call, so if we want to send results from another thread, senders from other threads should “kick” the message loop after sending the result by calling PostThreadMessage with an ignorable/unhandled message such as WM_APP.