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

# XAsyncRun

> XAsyncRun

# XAsyncRun

Asynchronously runs the specified callback function.

## Syntax

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

### Parameters

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

A pointer to the [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) that is used to track the asynchronous call.

*work*   \_In\_\
Type: [XAsyncWork\*](/reference/system/xasync/functions/xasyncwork)

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](/reference/errorcodes).

## 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](/reference/system/xasyncprovider/functions/xasyncbegin)
* [XAsyncComplete](/reference/system/xasyncprovider/functions/xasynccomplete)
* [XAsyncSchedule](/reference/system/xasyncprovider/functions/xasyncschedule)

For more information about implementing your own asynchronous functionality with `XAsyncProvider` and `XAsyncBlock`, 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

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

## See also

[XAsync Members](/reference/system/xasync/xasync_members)\
[XAsyncProvider Members](/reference/system/xasyncprovider/xasyncprovider_members)\
[Asynchronous Programming Model](/build/core-features/common/async/async-programming-model)


## Related topics

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