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

# XAsyncRun

> XAsyncRun

Asynchronously runs the specified callback function.

## Syntax

```cpp theme={null}
HRESULT XAsyncRun(  
         XAsyncBlock* asyncBlock,  
         XAsyncWork* work  
)  
```

### Parameters

*asyncBlock*   \_Inout\_\
Type: [XAsyncBlock\*](https://docs.xbox.com/reference/system/xasync/structs/xasyncblock.md)

A pointer to the [XAsyncBlock](https://docs.xbox.com/reference/system/xasync/structs/xasyncblock.md) that is used to track the asynchronous call.

*work*   \_In\_\
Type: [XAsyncWork\*](https://docs.xbox.com/reference/system/xasync/functions/xasyncwork.md)

A pointer to a callback function to run asynchronously.

### Return value

Type: [HRESULT](https://learn.microsoft.com/openspecs/windows_protocols/ms-erref/0642cb2f-2075-4469-918c-4441e69c548a)

Returns `S_OK` if successful; otherwise, returns an error code. For a list of error codes, see [Error Codes](https://docs.xbox.com/reference/errorcodes.md).

## Remarks

`XAsyncRun` is a helper function that asynchronously runs the callback function specified in *work*. You can use the `XAsyncBlock` specified in *asyncBlock* to cancel or get the status of the callback function. `XAsyncRun` internally uses the following `XAsyncProvider` functions to run and track the callback function:

* [XAsyncBegin](https://docs.xbox.com/reference/system/xasyncprovider/functions/xasyncbegin.md)
* [XAsyncComplete](https://docs.xbox.com/reference/system/xasyncprovider/functions/xasynccomplete.md)
* [XAsyncSchedule](https://docs.xbox.com/reference/system/xasyncprovider/functions/xasyncschedule.md)

For more information about implementing your own asynchronous functionality with `XAsyncProvider` and `XAsyncBlock`, see [Asynchronous Programming Model](https://docs.xbox.com/build/core-features/common/async/async-programming-model.md).

## Requirements

**Header:** XAsync.h

**Library:** xgameruntime.lib

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

## Conceptual documentation

* [Run Microsoft Game Development Kit (GDK) API task](https://docs.xbox.com/build/core-features/common/async/async-libraries/async-library-xasync-example-run-gdk-task.md)
* [Run simple task](https://docs.xbox.com/build/core-features/common/async/async-libraries/async-library-xasync-example-run-simple-task.md)
* [XAsync library overview](https://docs.xbox.com/build/core-features/common/async/async-libraries/async-library-xasync.md)
* [Set up cancelability](https://docs.xbox.com/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-cancelability.md)
* [Set up custom provider](https://docs.xbox.com/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-custom-provider.md)
* [Asynchronous Programming Model](https://docs.xbox.com/build/core-features/common/async/async-programming-model.md)
* [Generic async task wrapper](https://docs.xbox.com/build/core-features/common/async/async-task-function-example.md)

## See also

[XAsync Members](https://docs.xbox.com/reference/system/xasync/xasync_members.md)\
[XAsyncProvider Members](https://docs.xbox.com/reference/system/xasyncprovider/xasyncprovider_members.md)\
[Asynchronous Programming Model](https://docs.xbox.com/build/core-features/common/async/async-programming-model.md)


## Related topics

- [Run simple task](https://docs.xbox.com/build/core-features/common/async/async-libraries/async-library-xasync-example-run-simple-task.md)
- [XAsyncWork](https://docs.xbox.com/reference/system/xasync/functions/xasyncwork.md)
- [XAsync (API contents)](https://docs.xbox.com/reference/system/xasync/xasync_members.md)
- [Run Microsoft Game Development Kit (GDK) API task](https://docs.xbox.com/build/core-features/common/async/async-libraries/async-library-xasync-example-run-gdk-task.md)
- [Generic async task wrapper](https://docs.xbox.com/build/core-features/common/async/async-task-function-example.md)
