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

# XTaskQueueCallback

> XTaskQueueCallback

# XTaskQueueCallback

A callback that is invoked by the task queue.

## Syntax

```cpp theme={null}
void XTaskQueueCallback(  
         void* context,  
         bool canceled  
)  
```

### Parameters

*context*   \_In\_opt\_\
Type: void\*

Optional. A context pointer passed when calling [XTaskQueueSubmitCallback](/reference/system/xtaskqueue/functions/xtaskqueuesubmitcallback).

*canceled*   \_In\_\
Type: bool

If true, the callback is being canceled because the task queue is terminating.

### Return value

Type: void

## Remarks

The `XTaskQueueCallback` callback is implemented to perform work on a task queue. Callbacks can be submitted to either the work port or completion port of a task queue by invoking [XTaskQueueSubmitCallback](/reference/system/xtaskqueue/functions/xtaskqueuesubmitcallback) or [XTaskQueueSubmitDelayedCallback](/reference/system/xtaskqueue/functions/xtaskqueuesubmitdelayedcallback). The work port and completion port of a task queue can have independent dispatch modes, and `XTaskQueueCallback` callbacks can be submitted to either port. Typically, a callback submitted to a work port in turn submits a corresponding callback to the completion port upon completing its work.

The purpose of the `canceled` parameter is to ensure that any resources allocated by a callback can be properly released if a callback is canceled. If an `XTaskQueueCallback` callback is called and `canceled` is set to true, then the task queue for that callback has been terminated by calling [XTaskQueueTerminate](/reference/system/xtaskqueue/functions/xtaskqueueterminate) and the callback has been canceled. The callback should release any allocated resources, including the memory allocated in `context`, and perform no other work.

For an example, see [Submitting callbacks](/build/core-features/common/async/async-task-queue-design-howto/submitting-callbacks).

## Requirements

**Header:** XTaskQueue.h

**Library:** xgameruntime.lib

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

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

- [XTaskQueueSubmitCallback](/reference/system/xtaskqueue/functions/xtaskqueuesubmitcallback.md)
- [XTaskQueueSubmitDelayedCallback](/reference/system/xtaskqueue/functions/xtaskqueuesubmitdelayedcallback.md)
- [XTaskQueue](/reference/system/xtaskqueue/xtaskqueue_members.md)
- [Async task queue design](/build/core-features/common/async/async-task-queue-design.md)
- [XTaskQueueRegisterWaiter](/reference/system/xtaskqueue/functions/xtaskqueueregisterwaiter.md)
