-api-id | -api-type |
---|---|
E:Microsoft.UI.Dispatching.DispatcherQueue.ShutdownStarting |
winrt event |
Raised when either ShutdownQueue or ShutdownQueueAsync is called. For a full list of the events raised, and in what order, see the Remarks for ShutdownQueueAsync.
The ShutdownStarting event is raised from the event loop thread before the event loop exits. The handler for this event can take a deferral, and can continue to post work until the deferral completes. Once the deferral completes, the DispatcherQueue no longer accepts work, and DispatcherQueue.TryEnqueue returns false
.
_dispatcherQueue.ShutdownStarting += (s, e) =>
{
// Queue is shutting down, do this last operation to
// update state before the dispatcher loop exits
_queue.TryEnqueue(
() =>
{
// clean up state
});
};