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

# XAsyncWork

> XAsyncWork

# XAsyncWork

Represents the callback function invoked by [XAsyncRun](/reference/system/xasync/functions/xasyncrun).

## Syntax

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

### Parameters

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

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

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

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

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

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

## See also

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