Contents - Index - Top


No UI threads in an event

 

You should not start a new UI thread in any of the webview2 events.

 

For example if you popup a simple messagebox somewhere in an event, in order to return simple debugging info back to you, then the WebView2 control itself displays the following info in the debug window of your development environment.

 

Debug Output:

Running a message loop synchronously in an event handler in Webview can cause reentrancy issues. Please refer to https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/threading-model#re-entrancy for more information about the used threading model in WebView2.

 

This means that you should not create a new dialog or other UI directly from within an event. Instead of that, it is better to maintain state in the event for a variable or property and act on that state later on instead.

One way to do so is to start a timer from the event and start the new UI thread from that timer instead.

 


AntView - The MS Edge WebView2 ActiveX control Date last changed: 11/05/2025