Share via


DispatcherQueue.TryEnqueue 메서드

정의

오버로드

TryEnqueue(DispatcherQueueHandler)

DispatcherQueue와 연결된 스레드에서 실행되는 작업을 DispatcherQueue에 추가합니다.

TryEnqueue(DispatcherQueuePriority, DispatcherQueueHandler)

DispatcherQueue와 연결된 스레드에서 실행되는 작업을 DispatcherQueue에 추가합니다.

TryEnqueue(DispatcherQueueHandler)

DispatcherQueue와 연결된 스레드에서 실행되는 작업을 DispatcherQueue에 추가합니다.

public:
 virtual bool TryEnqueue(DispatcherQueueHandler ^ callback) = TryEnqueue;
/// [Windows.Foundation.Metadata.Overload("TryEnqueue")]
bool TryEnqueue(DispatcherQueueHandler const& callback);
[Windows.Foundation.Metadata.Overload("TryEnqueue")]
public bool TryEnqueue(DispatcherQueueHandler callback);
function tryEnqueue(callback)
Public Function TryEnqueue (callback As DispatcherQueueHandler) As Boolean

매개 변수

callback
DispatcherQueueHandler

실행할 작업입니다.

반환

Boolean

bool

True 이면 작업이 큐에 추가되었음을 나타냅니다. false, 그렇지 않으면 입니다.

특성

예제

// Create a new thread and initialize a DispatcherQueueController
// and run a DispatcherQueue event loop on it.

_queueController =
    DispatcherQueueController.CreateOnDedicatedThread();
_queue = _queueController.DispatcherQueue;

// This is the first TryEnqueue() after creating the DispatcherQueue
// The callback is guaranteed to be invoked first despite Priority on the
// newly created thread.

bool isQueued = _queue.TryEnqueue(
        () =>
        {
            // task to perform on another thread.
        });

설명

작업은 정상 우선 순위로 큐에 대기됩니다. 큐는 콜백 을 직렬로 우선 순위 순서로 호출합니다.

ShutdownQueueAsync()가 호출되면 큐는 새 작업을 큐에 대기하지 않으며 이 메서드는 false를 반환합니다.

적용 대상

TryEnqueue(DispatcherQueuePriority, DispatcherQueueHandler)

DispatcherQueue와 연결된 스레드에서 실행되는 작업을 DispatcherQueue에 추가합니다.

public:
 virtual bool TryEnqueue(DispatcherQueuePriority priority, DispatcherQueueHandler ^ callback) = TryEnqueue;
/// [Windows.Foundation.Metadata.Overload("TryEnqueueWithPriority")]
bool TryEnqueue(DispatcherQueuePriority const& priority, DispatcherQueueHandler const& callback);
[Windows.Foundation.Metadata.Overload("TryEnqueueWithPriority")]
public bool TryEnqueue(DispatcherQueuePriority priority, DispatcherQueueHandler callback);
function tryEnqueue(priority, callback)
Public Function TryEnqueue (priority As DispatcherQueuePriority, callback As DispatcherQueueHandler) As Boolean

매개 변수

priority
DispatcherQueuePriority

낮음, 보통 또는 높음과 같은 작업의 우선 순위입니다.

callback
DispatcherQueueHandler

실행할 태스크에 대한 대리자입니다.

반환

Boolean

bool

True 이면 작업이 큐에 추가되었음을 나타냅니다. false, 그렇지 않으면 입니다.

특성

예제

// Create a new thread and initialize a DispatcherQueueController
// and run a DispatcherQueue event loop on it.

_queueController =
    DispatcherQueueController.CreateOnDedicatedThread();
_queue = _queueController.DispatcherQueue;

// This is the first TryEnqueue() after creating the DispatcherQueue. The
// first TryEnqueue task is guaranteed //to be invoked first on the new
// thread, regardless of what priority it was enqueued at.


bool isQueued = _queue.TryEnqueue(Windows.System.DispatcherQueuePriority.High,
        () =>
        {
            // task to perform on another thread.
        });

설명

큐는 콜백 을 직렬로 우선 순위 순서로 호출합니다.

ShutdownQueueAsync()가 호출되면 큐는 새 작업을 큐에 대기하지 않으며 이 메서드는 false를 반환합니다.

적용 대상