> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XTaskQueue library overview

> XTaskQueue library overview

Use this topic to manage task queues with the XTaskQueue library. This library is responsible for the "when" and
"where" of running tasks, which is controlled by task queues
and the methods that  [set up](/reference/system/xtaskqueue/functions/xtaskqueuecreate),
[manage](/reference/system/xtaskqueue/functions/xtaskqueuedispatch), and [control](/reference/system/xtaskqueue/functions/xtaskqueueregistermonitor) task queues.

Task queues can have two ports set to [different
modes](/reference/system/xtaskqueue/enums/xtaskqueuedispatchmode) and dispatched on any thread.
[Custom callbacks](/reference/system/xtaskqueue/functions/xtaskqueueregisterwaiter) can be added to call in
special circumstances for functionality.

Each process has a default task queue that automatically dispatches its tasks concurrently
in the system thread pool. This task pool is used if no task queue is specified in the
[XAsyncBlock](/reference/system/xasync/structs/xasyncblock). You can [change or remove](/reference/system/xtaskqueue/functions/xtaskqueuesetcurrentprocesstaskqueue)
the default task queue.

For more information about XTaskQueue APIs, see [XTaskQueue](/reference/system/xtaskqueue/xtaskqueue_members).

## XTaskQueueHandle

When a task queue is created, it's tracked by an `XTaskQueueHandle` type.
This handle identifies the task queue and is passed to any function in the
[XTaskQueue library](/reference/system/xtaskqueue/xtaskqueue_members) that works with task queues. The handle must
be tracked and closed when it's no longer using the task queue.

For more information about cleaning up task queues, see [Cleanup task queue](/build/core-features/common/async/async-libraries/async-library-xtaskqueue-example-cleanup-task-queue).

## Reference API documentation

* [XTaskQueue (API contents)](/reference/system/xtaskqueue/xtaskqueue_members)
  * Functions
    * [xtaskqueuecreate](/reference/system/xtaskqueue/functions/xtaskqueuecreate)
    * [xtaskqueuedispatch](/reference/system/xtaskqueue/functions/xtaskqueuedispatch)
    * [xtaskqueueregistermonitor](/reference/system/xtaskqueue/functions/xtaskqueueregistermonitor)
    * [xtaskqueueregisterwaiter](/reference/system/xtaskqueue/functions/xtaskqueueregisterwaiter)
    * [xtaskqueuesetcurrentprocesstaskqueue](/reference/system/xtaskqueue/functions/xtaskqueuesetcurrentprocesstaskqueue)
* [xasync (API contents)](/reference/system/xasync/xasync_members)
  * Structures
    * [XAsyncBlock](/reference/system/xasync/structs/xasyncblock)

## See also

[Example: Create Task Queue](/build/core-features/common/async/async-libraries/async-library-xtaskqueue-example-create-task-queue)
[Example: Dispatch Task Queue](/build/core-features/common/async/async-libraries/async-library-xtaskqueue-example-dispatch-task-queue)
[Example: Cleanup Task Queue](/build/core-features/common/async/async-libraries/async-library-xtaskqueue-example-cleanup-task-queue)
[XAsync](/reference/system/xasync/xasync_members)
[Designing the task queue](/build/core-features/common/async/async-task-queue-design)
[XTaskQueue](/reference/system/xtaskqueue/xtaskqueue_members)


## Related topics

- [XTaskQueue](/reference/system/xtaskqueue/xtaskqueue_members.md)
- [Create task queue example](/build/core-features/common/async/async-libraries/async-library-xtaskqueue-example-create-task-queue.md)
- [Dispatch task queue example](/build/core-features/common/async/async-libraries/async-library-xtaskqueue-example-dispatch-task-queue.md)
- [Clean up task queue example](/build/core-features/common/async/async-libraries/async-library-xtaskqueue-example-cleanup-task-queue.md)
- [XTaskQueueSetCurrentProcessTaskQueue](/reference/system/xtaskqueue/functions/xtaskqueuesetcurrentprocesstaskqueue.md)
