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

# XAsyncWork

> XAsyncWork

Represents the callback function invoked by [XAsyncRun](https://docs.xbox.com/reference/system/xasync/functions/xasyncrun.md).

## Syntax

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

### Parameters

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

A pointer to a copy of the [XAsyncBlock](https://docs.xbox.com/reference/system/xasync/structs/xasyncblock.md) that was passed to [XAsyncRun](https://docs.xbox.com/reference/system/xasync/functions/xasyncrun.md).

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

A pointer to a copy of the [XAsyncBlock](https://docs.xbox.com/reference/system/xasync/structs/xasyncblock.md) that was passed to [XAsyncRun](https://docs.xbox.com/reference/system/xasync/functions/xasyncrun.md) is used to allow the system to ensure that the pointer always exists and is valid for the callback.

When using the [XAsyncRun](https://docs.xbox.com/reference/system/xasync/functions/xasyncrun.md) helper function to asynchronously run a callback function, you specify an `XAsyncWork` pointer for the callback function to be invoked. `XAsyncRun` then uses [XAsyncProvider](https://docs.xbox.com/reference/system/xasyncprovider/xasyncprovider_members.md) functionality to run the callback function.

For more information about `XAsyncProvider` functionality, 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

## See also

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


## Related topics

- [XAsyncRun](https://docs.xbox.com/reference/system/xasync/functions/xasyncrun.md)
- [XAsync (API contents)](https://docs.xbox.com/reference/system/xasync/xasync_members.md)
- [XAsyncBlock](https://docs.xbox.com/reference/system/xasync/structs/xasyncblock.md)
- [XAsyncSchedule](https://docs.xbox.com/reference/system/xasyncprovider/functions/xasyncschedule.md)
- [XAsyncOp](https://docs.xbox.com/reference/system/xasyncprovider/enums/xasyncop.md)
