DispatcherQueue.ShutdownStarting Event


Fires before the dispatcher queue initiates an exit from its event loop.

Equivalent WinUI event: Microsoft.System.DispatcherQueue.ShutdownStarting.

// Register
event_token ShutdownStarting(TypedEventHandler<DispatcherQueue, DispatcherQueueShutdownStartingEventArgs const&> const& handler) const;

// Revoke with event_token
void ShutdownStarting(event_token const* cookie) const;

// Revoke with event_revoker
DispatcherQueue::ShutdownStarting_revoker ShutdownStarting(auto_revoke_t, TypedEventHandler<DispatcherQueue, DispatcherQueueShutdownStartingEventArgs const&> const& handler) const;
public event TypedEventHandler<DispatcherQueue,DispatcherQueueShutdownStartingEventArgs> ShutdownStarting;
function onShutdownStarting(eventArgs) { /* Your code */ }
dispatcherQueue.addEventListener("shutdownstarting", onShutdownStarting);
dispatcherQueue.removeEventListener("shutdownstarting", onShutdownStarting);
- or -
dispatcherQueue.onshutdownstarting = onShutdownStarting;
Public Custom Event ShutdownStarting As TypedEventHandler(Of DispatcherQueue, DispatcherQueueShutdownStartingEventArgs) 

Event Type



_dispatcherQueue.ShutdownStarting += (s, e) =>
    // Queue is shutting down, do this last operation to  
    // update state before the dispatcher loop exits
        () =>
            // clean up state


The event is fired on the thread running the DispatcherQueue event loop.

This event fires before the DispatcherQueue initiates the exit from the event loop. Event handlers for this event can queue work from within the handler. The event handler can take a deferral and continue to post work to the DispatcherQueue until the deferral completes. Once the deferral completes, no new work will be accepted by the DispatcherQueue.

Applies to