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

# XTaskQueueSetCurrentProcessTaskQueue

> XTaskQueueSetCurrentProcessTaskQueue

# XTaskQueueSetCurrentProcessTaskQueue

Sets the given task queue as the process wide task queue.

## Syntax

```cpp theme={null}
void XTaskQueueSetCurrentProcessTaskQueue(  
         XTaskQueueHandle queue  
)  
```

### Parameters

*queue*   \_In\_\
Type: XTaskQueueHandle

The queue to set up as the default task queue for the process.

### Return value

Type: void

## Remarks

<Note>This function isn't safe to call on a time-sensitive thread. For more information, see [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads).</Note>

The queue can be set to nullptr, in which case [XTaskQueueGetCurrentProcessTaskQueue](/reference/system/xtaskqueue/functions/xtaskqueuegetcurrentprocesstaskqueue) will also return nullptr. The provided queue will have its handle duplicated and any existing process task queue will have its handle closed.

The following example replaces the default process task queue. This 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. The process task queue can also be set to **nullptr**, in which case Microsoft Game Development Kit (GDK) APIs that require a task queue parameter will error with E\_NO\_TASK\_QUEUE if null was provided. This allows Microsoft Game Development Kit (GDK) APIs to function with defaults while still allowing tight control over task queue handles if needed.

```cpp theme={null}
void UsingProcessTaskQueue()
{
    XTaskQueueHandle queue = nullptr;
    XTaskQueueGetCurrentProcessTaskQueue(&queue);

    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;
    }
}
```

## Requirements

**Header:** XTaskQueue.h

**Library:** xgameruntime.lib

**Supported platforms:** Windows, XBOX One family consoles and XBOX Series consoles

## Conceptual documentation

* [XTaskQueue library overview](/build/core-features/common/async/async-libraries/async-library-xtaskqueue)
* [Asynchronous programming design goals and improvements](/build/core-features/common/async/async-whitepaper)
* [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## See also

[XTaskQueue members](/reference/system/xtaskqueue/xtaskqueue_members)\
[Asynchronous Programming Model](/build/core-features/common/async/async-programming-model)\
[Async Task Queue Design](/build/core-features/common/async/async-task-queue-design)


## Related topics

- [XTaskQueueGetCurrentProcessTaskQueue](/reference/system/xtaskqueue/functions/xtaskqueuegetcurrentprocesstaskqueue.md)
- [XTaskQueue](/reference/system/xtaskqueue/xtaskqueue_members.md)
- [How to use XBOX Services APIs (XSAPIs)](/services/xbox-services/fundamentals/xbox-services-api/live-gs-xbl-apis.md)
- [How to: Using the process task queue](/build/core-features/common/async/async-task-queue-design-howto/using-process-task-queue.md)
- [XTaskQueue library overview](/build/core-features/common/async/async-libraries/async-library-xtaskqueue.md)
