WebView2.EnsureCoreWebView2Async(CoreWebView2Environment) Method


Explicitly trigger initialization of the control's CoreWebView2.

public System.Threading.Tasks.Task EnsureCoreWebView2Async (Microsoft.Web.WebView2.Core.CoreWebView2Environment environment = default);
member this.EnsureCoreWebView2Async : Microsoft.Web.WebView2.Core.CoreWebView2Environment -> System.Threading.Tasks.Task
Public Function EnsureCoreWebView2Async (Optional environment As CoreWebView2Environment = Nothing) As Task



A pre-created CoreWebView2Environment that should be used to create the CoreWebView2. Creating your own environment gives you control over several options that affect how the CoreWebView2 is initialized. If you pass null (the default value) then a default environment will be created and used automatically.



A Task that represents the background initialization process. When the task completes then the CoreWebView2 property will be available for use (i.e. non-null). Note that the control's CoreWebView2InitializationCompleted event will be invoked before the task completes or on exceptions.


Thrown when invoked from non-UI thread.


Calling this method additional times will have no effect (any specified environment is ignored) and return the same Task as the first call. Calling this method after initialization has been implicitly triggered by setting the Source property will have no effect (any specified environment is ignored) and simply return a Task representing that initialization already in progress.

Applies to