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

# XAsyncCompletionRoutine

> XAsyncCompletionRoutine

# XAsyncCompletionRoutine

Represents the completion callback for an asynchronous call.

## Syntax

```cpp theme={null}
void XAsyncCompletionRoutine(  
         XAsyncBlock* asyncBlock  
)  
```

### Parameters

*asyncBlock*   \_Inout\_\
Type: [XAsyncBlock\*](/reference/system/xasync/structs/xasyncblock)

A pointer to the [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) for the completion callback.

### Return value

Type: void

## Remarks

You can optionally specify an `XAsyncCompletionRoutine` pointer to provide a *completion callback* for an asynchronous call. A completion callback is a callback function that executes after the completion of an asynchronous call. You can specify an `XAsyncCompletionRoutine` pointer in the `callback` member of an [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) structure for an asynchronous call.

Typically, a completion callback processes the results of an asynchronous call on another thread. The completion callback represents a callback function that is invoked when the asynchronous call completes. The callback function takes an `XAsyncBlock` pointer, which is subsequently used to obtain the results of the callback function.

If you specify a completion callback, you can periodically check if the completion callback is completed by using the [XAsyncGetStatus](/reference/system/xasync/functions/xasyncgetstatus) function, and then use [XAsyncGetResult](/reference/system/xasyncprovider/functions/xasyncgetresult) and [XAsyncGetResultSize](/reference/system/xasync/functions/xasyncgetresultsize) as needed to get the results from the completed task.

A completion callback is invoked even if [XAsyncCancel](/reference/system/xasync/functions/xasynccancel) is invoked to cancel the asynchronous call.

Use [XAsyncGetStatus](/reference/system/xasync/functions/xasyncgetstatus) or the completion callback's `Get\*Result` method to obtain the results of the asynchronous call. If the asynchronous call was canceled these methods return `E_ABORT`. For more information about the implementation pattern of an asynchronous provider, including the `Get\*Result` method, see [Asynchronous Programming Model](/build/core-features/common/async/async-programming-model).

## Requirements

**Header:** XAsync.h

**Library:** xgameruntime.lib

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

## Conceptual documentation

* [Asynchronous Programming Model](/build/core-features/common/async/async-programming-model)

## See also

[XAsync Members](/reference/system/xasync/xasync_members)\
[XAsyncGetStatus](/reference/system/xasync/functions/xasyncgetstatus)\
[Asynchronous Programming Model](/build/core-features/common/async/async-programming-model)


## Related topics

- [XAsyncCancel](/reference/system/xasync/functions/xasynccancel.md)
- [XAsync](/reference/system/xasync/xasync_members.md)
- [XAsyncBlock](/reference/system/xasync/structs/xasyncblock.md)
- [Asynchronous Programming Model](/build/core-features/common/async/async-programming-model.md)
- [XMEMALLOC_ROUTINE callback](/reference/system/xmem/functions/xmemalloc_routine.md)
