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

# XAsync library overview

> XAsync library overview

The [XAsync](/reference/system/xasync/xasync_members) library provides methods and data that define async tasks and their callbacks. The main async primitive, [XAsyncBlock](/reference/system/xasync/structs/xasyncblock), is defined in this library. It's a
requirement for all async tasks.

Beyond the async block, this library provides methods to [start basic async calls](/reference/system/xasync/functions/xasyncrun), [get async task status](/reference/system/xasync/functions/xasyncgetstatus), and [attempt to cancel tasks](/reference/system/xasync/functions/xasynccancel).

<a id="xasyncblock" />

## XAsyncBlock

The [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) is the main async primitive that contains members that are used for implementing the completion callback, providing data to the completion callback, and choosing a task queue to run in.

The async block also contains private data that's used internally by the system for runtime behavior. As a result, this block can't be shared between multiple active tasks. The system uses this data to identify the async call while the call is active.

```c++ theme={null}
struct XAsyncBlock
{
    /// <summary>
    /// The queue to queue the call on.
    /// </summary>
    XTaskQueueHandle queue;
    
    /// <summary>
    /// Optional context pointer to pass to the callback.
    /// </summary>
    void* context;
    
    /// <summary>
    /// Optional callback that is invoked when the call completes.
    /// </summary>
    XAsyncCompletionRoutine* callback;
    
    /// <summary>
    /// Internal use only.
    /// </summary>
    unsigned char internal[sizeof(void*) * 4];
};
```

## Reference API documentation

* [XAsync (API contents)](/reference/system/xasync/xasync_members)
  * Functions
    * [xasyncrun](/reference/system/xasync/functions/xasyncrun)
    * [xasyncgetstatus](/reference/system/xasync/functions/xasyncgetstatus)
    * [xasynccancel](/reference/system/xasync/functions/xasynccancel)
  * Structures
    * [XAsyncBlock](/reference/system/xasync/structs/xasyncblock)

## See also

[Setup async task](/build/core-features/common/async/async-libraries/async-library-xasync-example-setup-async-task)
[Run simple task](/build/core-features/common/async/async-libraries/async-library-xasync-example-run-simple-task)
[Run Microsoft Game Development Kit API task](/build/core-features/common/async/async-libraries/async-library-xasync-example-run-gdk-task)
[XAsync system API contents](/reference/system/xasync/xasync_members)


## Related topics

- [XAsync](/reference/system/xasync/xasync_members.md)
- [XAsyncBlock](/reference/system/xasync/structs/xasyncblock.md)
- [Set up async task example](/build/core-features/common/async/async-libraries/async-library-xasync-example-setup-async-task.md)
- [XAsyncCancel](/reference/system/xasync/functions/xasynccancel.md)
- [Asynchronous Programming Overview](/build/core-features/common/async/async-toc.md)
