> ## 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.

# How to: Using the process task queue

> How to: Using the process task queue

## Example

The default *process task queue* uses the thread pool for both work and completion dispatching. Microsoft Game Development Kit (GDK) APIs that take task queue parameters all accept `nullptr` and substitute the process task queue. It can be replaced. The process task queue can also be set to `nullptr`. In this case, Microsoft Game Development Kit (GDK) APIs that require a task queue parameter will error with `E_NO_TASK_QUEUE`. This allows the Microsoft Game Development Kit (GDK) APIs to function with defaults while still allowing tight control over task queue handles, if needed.

The following example shows how to use the process task queue.

```c++ theme={null}
void UsingProcessTaskQueue()  
{  
    XTaskQueueHandle queue = GetCurrentProcessTaskQueue();  
  
    auto callback = [](void*, bool)  
    {  
        printf("Work callback invoked.\r\n");  
    };  
  
    HRESULT hr = XTaskQueueSubmitCallback(  
        queue, XTaskQueuePort::Work,  
        nullptr, callback);  
  
    if (FAILED(hr))  
    {  
        printf("Failed to submit callback: %x\r\n", hr);  
        return;  
    }  
  
    // You can replace the process task queue.  
    hr = XTaskQueueCreate(  
        XTaskQueueDispatchMode::Manual,  
        XTaskQueueDispatchMode::Manual,  
        &queue);  
  
    if (FAILED(hr))  
    {  
        printf("Failed to create new task queue: %x\r\n", hr);  
        return;  
    }  
  
    XTaskQueueSetCurrentProcessTaskQueue(queue);  
  
    XTaskQueueHandle processQueue;  
    XTaskQueueGetCurrentProcessTaskQueue(&processQueue);  
    printf("Process task queue: %p. Our queue: %p\r\n",  
        processQueue, queue);  
    XTaskQueueCloseHandle(processQueue);  
  
    // You can set the process queue to nullptr to force everyone to pass a queue  
    // as a parameter.  
    XTaskQueueSetCurrentProcessTaskQueue(nullptr);  
    XTaskQueueGetCurrentProcessTaskQueue(&processQueue);  
    printf("Process task queue: %p.\r\n",  
        processQueue);  
}  
```

## See also

[Designing the task queue](/build/core-features/common/async/async-task-queue-design)


## Related topics

- [Async task queue design](/build/core-features/common/async/async-task-queue-design.md)
- [How to: Using a task queue waiter](/build/core-features/common/async/async-task-queue-design-howto/using-task-queue-waiter.md)
- [How to: Using a task queue with a Windows message loop](/build/core-features/common/async/async-task-queue-design-howto/task-queue-windows-msg-loop.md)
- [XTaskQueueGetCurrentProcessTaskQueue](/reference/system/xtaskqueue/functions/xtaskqueuegetcurrentprocesstaskqueue.md)
- [How to: Creating a manual task queue](/build/core-features/common/async/async-task-queue-design-howto/creating-manual-task-queue.md)
