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

表示由 [XAsyncRun](/reference/system/xasync/functions/xasyncrun) 调用的回调函数。

## Syntax

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

### Parameters

*asyncBlock*   \_Inout\_\
类型：[XAsyncBlock\*](/reference/system/xasync/structs/xasyncblock)

指向传递给 [XAsyncRun](/reference/system/xasync/functions/xasyncrun) 的 [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) 副本的指针。

### Return value

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

成功时返回 `S_OK`；否则，返回错误代码。有关错误代码列表，请参阅[错误代码](/reference/errorcodes)。

## Remarks

使用指向传递给 [XAsyncRun](/reference/system/xasync/functions/xasyncrun) 的 [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) 副本的指针，可让系统确保该指针始终存在并对回调有效。

使用 [XAsyncRun](/reference/system/xasync/functions/xasyncrun) 帮助程序函数以异步方式运行回调函数时，请为要调用的回调函数指定一个 `XAsyncWork` 指针。然后，`XAsyncRun` 使用 [XAsyncProvider](/reference/system/xasyncprovider/xasyncprovider_members) 功能运行该回调函数。

有关 `XAsyncProvider` 功能的详细信息，请参阅[异步编程模型](/build/core-features/common/async/async-programming-model)。

## Requirements

**头文件：** XAsync.h

**库：** xgameruntime.lib

**受支持的平台：** Windows、XBOX One 系列主机和 XBOX Series 主机

## See also

[XAsync Members](/reference/system/xasync/xasync_members)\
[XAsyncRun](/reference/system/xasync/functions/xasyncrun)\
[异步编程模型](/build/core-features/common/async/async-programming-model)


## Related topics

- [XAsyncRun](/zh-CN/reference/system/xasync/functions/xasyncrun.md)
- [XAsync](/zh-CN/reference/system/xasync/xasync_members.md)
- [XAsyncBlock](/zh-CN/reference/system/xasync/structs/xasyncblock.md)
- [PartyWorkMode](/zh-CN/services/playfab/multiplayer/networking/reference/enums/partyworkmode.md)
- [XAsyncOp](/zh-CN/reference/system/xasyncprovider/enums/xasyncop.md)
