Skip to main content

XTaskQueueCreate

Creates a task queue, which can be used to queue and dispatch calls.

Syntax

Parameters

workDispatchMode   _In_
Type: XTaskQueueDispatchMode
The dispatch mode for the “work” port of the queue. completionDispatchMode   _In_
Type: XTaskQueueDispatchMode
The dispatch mode for the “completion” port of the queue. queue   _Out_
Type: XTaskQueueHandle*
The newly created queue.

Return value

Type: HRESULT HRESULT success or error code.

Remarks

This function isn’t safe to call on a time-sensitive thread. For more information, see Time-sensitive threads.
Task queues are reference counted objects. Release the reference by calling XTaskQueueCloseHandle. A task queue has work and completion ports and tasks can be queued to either port. Each port can be configured with its own dispatch mode. For most scenarios, you create a task queue with the XTaskQueueCreate API. If you are chaining multiple asynchronous calls together, however, sometimes it is useful to create a composite queue via XTaskQueueCreateComposite. Consider an API whose implementation needs to invoke another API that uses a task queue. You may want to redirect the completion callback of the API so it doesn’t tie up the completion thread of the caller. In this case, you can create a composite task queue whose work and completion ports are built from the work port of another queue. The following example creates a task queue that dispatches both work and completion callbacks on the system thread pool.
SubmitCallback is a helper function that is defined in the code example for the XTaskQueueSubmitCallback function.
The following example creates a manually-pumped task queue. It creates two STL threads that dispatch calls for both the work and completion ports.
SubmitCallback is a helper function that is defined in the code example for the XTaskQueueSubmitCallback function.

Requirements

Header: XTaskQueue.h Library: xgameruntime.lib Supported platforms: Windows, XBOX One family consoles and XBOX Series consoles

Conceptual documentation

See also

XTaskQueue members
Asynchronous Programming Model
Async Task Queue Design
Last modified on August 20, 2026