Compartir a través de


CoreWebView2Environment.NewBrowserVersionAvailable Event

Definition

NewBrowserVersionAvailable is raised when a newer version of the WebView2 Runtime is installed and available using WebView2.

public event EventHandler<object> NewBrowserVersionAvailable;
member this.NewBrowserVersionAvailable : EventHandler<obj> 
Public Custom Event NewBrowserVersionAvailable As EventHandler(Of Object) 

Event Type

Examples

// A new version of the WebView2 Runtime is available, our handler gets called.
// We close our WebView and set a handler to reinitialize it once the WebView2
// Runtime collection of processes are gone, so we get the new version of the
// WebView2 Runtime.
void Environment_NewBrowserVersionAvailable(object sender, object e)
{
    if (((App)Application.Current).newRuntimeEventHandled)
    {
        return;
    }

    ((App)Application.Current).newRuntimeEventHandled = true;
    System.Threading.SynchronizationContext.Current.Post((_) =>
    {
        UpdateIfSelectedByUser();
    }, null);
}

Remarks

To use the newer version of the browser you must create a new environment and WebView. The event is only raised for new version from the same WebView2 Runtime from which the code is running. When not running with installed WebView2 Runtime, no event is raised.

Because a user data folder is only able to be used by one browser process at a time, if you want to use the same user data folder in the WebViews using the new version of the browser, you must close the environment and instance of WebView that are using the older version of the browser first. Or simply prompt the user to restart the app.

Applies to