Idioma

CoreWebView2ServiceWorkerRegistration.ServiceWorkerActivated Event

Definition

This event is raised when a service worker is activated. A service worker is activated when its script has been successfully registered and it is ready to control the pages within the scope of the registration.

This event is also raised when an updated version of a service worker reaches the active state.

In such a case, the existing CoreWebView2ServiceWorker object is being destroyed, and this event is raised with a new CoreWebView2ServiceWorker object representing the updated service worker. The active service worker is the one that receives fetch and message events for the pages it controls. See the Service Worker documentation for more information.

If you register for the ServiceWorkerActivated event and the registration already has an active worker, the event handler is not called immediately. Instead, it waits for the next activation event to occur. Therefore, you should first check if an active service worker is running by using the ActiveServiceWorker property.

public event EventHandler<Microsoft.Web.WebView2.Core.CoreWebView2ServiceWorkerActivatedEventArgs> ServiceWorkerActivated;
member this.ServiceWorkerActivated : EventHandler<Microsoft.Web.WebView2.Core.CoreWebView2ServiceWorkerActivatedEventArgs> 
Public Custom Event ServiceWorkerActivated As EventHandler(Of CoreWebView2ServiceWorkerActivatedEventArgs) 

Event Type

Applies to