DispatcherQueueController.ShutdownQueueAsync Método

Definição

Interrompe de forma assíncrona o DispatcherQueue associado a este DispatcherQueueController e desliga o thread se o DispatcherQueueController foi criado por CreateOnDedicatedThread.

Esse método retorna (uma operação assíncrona) assim que a operação de desligamento é iniciada; mas a operação assíncrona não é concluída até que a operação de desligamento seja concluída.

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

Retornos

Uma operação assíncrona, que será concluída após a fila ter despachado todo o trabalho restante.

Atributos

Exemplos

// 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);
        };
    }
}

Comentários

Quando você chama ShutdownQueueAsync, os seguintes eventos são gerados, nesta ordem:

Esses eventos são membros do objeto DispatcherQueue e sua finalidade é notificar os ouvintes de que o DispatcherQueue está sendo desligado. Os eventos são gerados no thread que executa o loop de evento DispatcherQueue em si.

Aplica-se a