Freigeben über


CoreWebView2Environment.UpdateRuntimeAsync Method

Definition

Try to update the installed Microsoft Edge WebView2 Runtime.

public System.Threading.Tasks.Task<Microsoft.Web.WebView2.Core.CoreWebView2UpdateRuntimeResult> UpdateRuntimeAsync ();
member this.UpdateRuntimeAsync : unit -> System.Threading.Tasks.Task<Microsoft.Web.WebView2.Core.CoreWebView2UpdateRuntimeResult>
Public Function UpdateRuntimeAsync () As Task(Of CoreWebView2UpdateRuntimeResult)

Returns

Examples

CoreWebView2UpdateRuntimeResult result = await _iWebView2.CoreWebView2.Environment.UpdateRuntimeAsync();
string update_result = "status: " + result.Status + ", extended error:" + result.ExtendedError;
MessageBox.Show(this, update_result, "UpdateRuntimeAsync result");

Remarks

This will potentially result in a new version of the Edge WebView2 Runtime being installed and NewBrowserVersionAvailable event being raised. There is no guarantee on the order of that event being raised and the completed handler being invoked. Besides the NewBrowserVersionAvailable event, there will be no impact to any currently running WebView2s when the update is installed.

Even though the Edge WebView2 Runtime update is installed for the machine and available to all users, the update will happen silently and not show elevation prompt. This will not impact Edge browser installations.

The latest version can always be queried using the GetAvailableBrowserVersionString(String) API.

The UpdateRuntimeAsync() method is only supported for an installed Edge WebView2 Runtime. When running a fixed version Edge WebView2 Runtime or non stable channel Edge browser, this API will return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED).

There could only be one active UpdateRuntime operation in an app process, calling this API before previous call is completed will fail with HRESULT_FROM_WIN32(ERROR_BUSY). Calling this API repeatedly in a short period of time, will also fail with HRESULT_FROM_WIN32(ERROR_BUSY). To protect accidental abuse of the update service, the implementation throttles the calls of this API to 3 times within 5 minutes in a process. The exact throttling limit can change in the future.

Edge update service can only support one update request at a time globally. If there is already an update operation running in the Edge update service, the result will be a @CoreWebView2UpdateRuntimeResult with @CoreWebView2UpdateRuntimeStatus$.UpdateAlreadyRunning. As the running update could succeed or fail, the app should retry later if NewBrowserVersionAvailable event has not been raised.

The UpdateRuntime operation is associated with the CoreWebView2Environment object and any ongoing UpdateRuntime operation will be aborted when the associated CoreWebView2Environment along with the CoreWebView2 objects that are created by the CoreWebView2Environment object are all released. In this case, the result will be a @CoreWebView2UpdateRuntimeResult with @CoreWebView2UpdateRuntimeStatus$.Failed @CoreWebView2UpdateRuntimeResult.Status and `E_ABORT` @CoreWebView2UpdateRuntimeResult.ExtendedError.

Applies to