CreateDispatcherQueueController function (dispatcherqueue.h)

Creates a DispatcherQueueController on the caller's thread. Use the created DispatcherQueueController to create and manage the lifetime of a DispatcherQueue to run queued tasks in priority order on the Dispatcher queue's thread.


HRESULT CreateDispatcherQueueController(
  [in]  DispatcherQueueOptions     options,
  [out] PDISPATCHERQUEUECONTROLLER *dispatcherQueueController


[in] options

The threading affinity and type of COM apartment for the created DispatcherQueueController. See remarks for details.

[out] dispatcherQueueController

The created dispatcher queue controller.

Important  The DispatcherQueueController is a WinRT object.

Return value

S_OK for success; otherwise a failure code.


Introduced in Windows 10, version 1709.

If options.threadType is DQTYPE_THREAD_DEDICATED, then this function creates the dedicated thread and then creates the DispatcherQueueController on that thread. The dispatcher queue event loop runs on the new dedicated thread.

An event loop runs asynchronously on a background thread to dispatch queued task items to the new dedicated thread.

If options.threadType is DQTYPE_THREAD_CURRENT, then the DispatcherQueueController instance is created on the current thread. An error results if there is already a IDispatcherQueueController on the current thread. If you create a dispatcher queue on the current thread, ensure that there is a message pump running on the current thread so that the dispatcher queue can use it to dispatch tasks.

This call does not return until the new thread and DispatcherQueueController are created. The new thread will be initialized using the specified COM apartment.

Important  The DispatcherQueueController, and its associated DispatcherQueue, are WinRT objects. See their documentation for usage details.


Target Platform Windows
Header dispatcherqueue.h
Library CoreMessaging.lib
DLL CoreMessaging.dll

See also