Partage via


DispatcherQueueController.ShutdownQueueAsync Méthode

Définition

Arrête de façon asynchrone le DispatcherQueue associé à ce DispatcherQueueController et arrête le thread si dispatcherQueueController a été créé par CreateOnDedicatedThread.

Cette méthode retourne (une opération asynchrone) dès que l’opération d’arrêt est démarrée ; mais l’opération asynchrone ne se termine pas tant que l’opération d’arrêt n’est pas terminée.

public:
 virtual IAsyncAction ^ ShutdownQueueAsync() = ShutdownQueueAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncAction ShutdownQueueAsync();
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncAction ShutdownQueueAsync();
function shutdownQueueAsync()
Public Function ShutdownQueueAsync () As IAsyncAction

Retours

Opération asynchrone, qui se termine une fois que la file d’attente a distribué tout son travail restant.

Attributs

Exemples

// Shutdown the event loop
public async void ShutdownLoop()
{
    if (_queueController != null)
    {
        // The await will complete after the event loop exits
        await _queueController.ShutdownQueueAsync();
        _queueController = null;
        _queue = null;
    }
}

// Another class that has access to the dedicated thread’s DispatcherQueue.
public class ModuleA
{
    public async void ShutdownSetup()
    {
        // Gets the DispatcherQueue for the dedicated thread

        // Invoked when controller begins the ShutdownQueueAsync.
        _dispatcherQueue.ShutdownStarting += (s, e) =>
        {
            // Queue is shutting down, do this last operation which
            // will update state before the loop exits
            _queue.TryEnqueue(
                () =>
                {
                    FinalInThreadCleanup(_myState);
                });
        };

        // Invoked after the DispatcherQueue event loop exits.
        _dispatcherQueue.ShutdownCompleted += (s, e) =>
        {
            CleanUp(_myState);
        };
    }
}

Remarques

Lorsque vous appelez ShutdownQueueAsync, les événements suivants sont déclenchés, dans cet ordre :

Ces événements sont membres de l’objet DispatcherQueue et leur objectif est d’informer les écouteurs que dispatcherQueue est en cours d’arrêt. Les événements sont déclenchés sur le thread qui exécute la boucle d’événements DispatcherQueue elle-même.

S’applique à