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

# 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](https://docs.xbox.com/reference/system/xtaskqueue/functions/xtaskqueuesubmitcallback.md).

*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](https://docs.xbox.com/reference/system/xtaskqueue/functions/xtaskqueuesubmitcallback.md) or [XTaskQueueSubmitDelayedCallback](https://docs.xbox.com/reference/system/xtaskqueue/functions/xtaskqueuesubmitdelayedcallback.md). 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](https://docs.xbox.com/reference/system/xtaskqueue/functions/xtaskqueueterminate.md) 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](https://docs.xbox.com/build/core-features/common/async/async-task-queue-design-howto/submitting-callbacks.md).

## Requirements

**Header:** XTaskQueue.h

**Library:** xgameruntime.lib

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

## See also

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


## Related topics

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