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

# XAsyncCompletionRoutine

> XAsyncCompletionRoutine

# XAsyncCompletionRoutine

表示异步调用的完成回调。

## Syntax

```cpp theme={null}
void XAsyncCompletionRoutine(  
         XAsyncBlock* asyncBlock  
)  
```

### Parameters

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

指向该完成回调的 [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) 的指针。

### Return value

类型：void

## Remarks

可以选择指定一个 `XAsyncCompletionRoutine` 指针来为异步调用提供*完成回调*。完成回调是在异步调用完成后执行的回调函数。可以在异步调用的 [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) 结构的 `callback` 成员中指定一个 `XAsyncCompletionRoutine` 指针。

通常，完成回调在另一线程上处理异步调用的结果。完成回调表示在异步调用完成时调用的回调函数。此回调函数采用一个 `XAsyncBlock` 指针，该指针随后用于获取回调函数的结果。

如果指定了完成回调，可以使用 [XAsyncGetStatus](/reference/system/xasync/functions/xasyncgetstatus) 函数定期检查完成回调是否已完成，然后根据需要使用 [XAsyncGetResult](/reference/system/xasyncprovider/functions/xasyncgetresult) 和 [XAsyncGetResultSize](/reference/system/xasync/functions/xasyncgetresultsize) 获取已完成任务的结果。

即使调用 [XAsyncCancel](/reference/system/xasync/functions/xasynccancel) 取消异步调用，也会调用完成回调。

使用 [XAsyncGetStatus](/reference/system/xasync/functions/xasyncgetstatus) 或完成回调的 `Get\*Result` 方法来获取异步调用的结果。如果异步调用已取消，这些方法将返回 `E_ABORT`。有关异步提供程序的实现模式（包括 `Get\*Result` 方法）的详细信息，请参阅[异步编程模型](/build/core-features/common/async/async-programming-model)。

## Requirements

**头文件：** XAsync.h

**库：** xgameruntime.lib

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

## Conceptual documentation

* [异步编程模型](/build/core-features/common/async/async-programming-model)

## See also

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


## Related topics

- [XAsyncCancel](/zh-CN/reference/system/xasync/functions/xasynccancel.md)
- [XAsync](/zh-CN/reference/system/xasync/xasync_members.md)
- [异步编程模型](/zh-CN/build/core-features/common/async/async-programming-model.md)
- [XAsyncBlock](/zh-CN/reference/system/xasync/structs/xasyncblock.md)
- [XMEMALLOC_ROUTINE callback](/zh-CN/reference/system/xmem/functions/xmemalloc_routine.md)
