CoreDispatcher.RunIdleAsync method

Applies to Windows and Windows Phone

Schedules a callback on the UI thread from a worker thread at idle priority, and returns the results asynchronously.


public IAsyncAction RunIdleAsync(
  IdleDispatchedHandler agileCallback



Type: IdleDispatchedHandler

The callback on which the idle priority dispatcher returns when the event is dispatched.

Return value

Type: IAsyncAction

Object that contains the results of the asynchronous action.


The RunIdleAsync method is very similar to CoreDispatcher::RunAsync, except that it always schedules the work item at CoreDispatcherPriority::Low priority. When you schedule a work item by calling RunIdleAsync from a worker thread, the work item is processed only when there are no event messages pending in the queue. This allows your app to perform tasks such as spell check or other discrete processing while the system is idle. If the IdleDispatchedHandler delegate returned by the callback has the IsDispatcherIdle property set to false, the work item immediately exits background processing until the event queue is empty again.

However, while your app is processing a background task, it can continue processing as long as there are no event messages pending in the CoreDispatcher event message queue. If your app receives an event message in the queue, then it must break out of the background processing. To determine when your app must exit background processing, access the IsDispatcherIdle property on the IdleDispatchedHandlerArgs object returned by the IdleDispatchedHandler callback you provided to RunIdleAsync. If there is a message, exit background processing and set the priority to CoreDispatcherPriority::Normal. Otherwise, if the callback continues to run without checking the dispatcher status, it could lead to input starvation.


Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8


Windows::UI::Core [C++]



See also




© 2014 Microsoft