Share via


DispatcherQueueController.ShutdownQueueAsync 메서드

정의

DispatcherQueueController와 연결된 DispatcherQueue를 비동기적으로 중지하고 CreateOnDedicatedThread에서 DispatcherQueueController를 만든 경우 스레드를 종료합니다.

이 메서드는 종료 작업이 시작되는 즉시 (비동기 작업)를 반환합니다. 그러나 비동기 작업은 종료 작업이 완료될 때까지 완료되지 않습니다.

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

반환

큐가 나머지 작업을 모두 디스패치한 후 완료되는 비동기 작업입니다.

특성

예제

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

설명

ShutdownQueueAsync를 호출하면 다음 이벤트가 순서대로 발생합니다.

이러한 이벤트는 DispatcherQueue 개체의 멤버이며, 그 목적은 수신기에 DispatcherQueue 가 종료되고 있음을 알리는 것입니다. 이벤트는 DispatcherQueue 이벤트 루프 자체를 실행하는 스레드에서 발생합니다.

적용 대상