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

Une opération asynchrone, qui se termine une fois la file d’attente distribuée tout son travail restant.

Attributs

Exemples

// Shut down 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 the 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 de notifier aux écouteurs que dispatcherQueue est arrêté. Les événements sont déclenchés sur le thread exécutant la boucle d’événements DispatcherQueue elle-même.

S’applique à