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

# XAsyncGetStatus

> XAsyncGetStatus

# XAsyncGetStatus

返回异步调用的状态，可选择等待其完成。

## Syntax

```cpp theme={null}
HRESULT XAsyncGetStatus(  
         XAsyncBlock* asyncBlock,  
         bool wait  
)  
```

### Parameters

*asyncBlock*   \_Inout\_\
类型：[XAsyncBlock\*](https://docs.xbox.com/zh-CN/reference/system/xasync/structs/xasyncblock.md)

指向传递给异步调用的 [XAsyncBlock](https://docs.xbox.com/zh-CN/reference/system/xasync/structs/xasyncblock.md) 的指针。

*wait*   \_In\_\
类型：bool

如果为 true，则 `XAsyncGetStatus` 会等待异步调用完成或被取消。

### Return value

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

成功时返回 `S_OK`；否则，返回错误代码。有关错误代码列表，请参阅[错误代码](https://docs.xbox.com/zh-CN/reference/errorcodes.md)。

## Remarks

异步调用完成后，如果该异步调用具有结果数据负载，则可以调用 [XAsyncGetResult](https://docs.xbox.com/zh-CN/reference/system/xasyncprovider/functions/xasyncgetresult.md) 来获取结果。如果异步调用没有结果数据负载，则无需调用 [XAsyncGetResult](https://docs.xbox.com/zh-CN/reference/system/xasyncprovider/functions/xasyncgetresult.md)。

**注意：** 完成回调和 wait 参数为 true 的 `XAsyncGetStatus` 都可用于确定调用何时完成。这些调用的顺序可能不明确，因此作为最佳实践，不应对同一调用同时使用两者。

## Requirements

**头文件：** XAsync.h

**库：** xgameruntime.lib

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

## Conceptual documentation

* [运行简单任务](https://docs.xbox.com/zh-CN/build/core-features/common/async/async-libraries/async-library-xasync-example-run-simple-task.md)
* [XAsync 库概述](https://docs.xbox.com/zh-CN/build/core-features/common/async/async-libraries/async-library-xasync.md)
* [设置自定义提供程序](https://docs.xbox.com/zh-CN/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-custom-provider.md)
* [异步编程模型](https://docs.xbox.com/zh-CN/build/core-features/common/async/async-programming-model.md)
* [异步编程的设计目标和改进](https://docs.xbox.com/zh-CN/build/core-features/common/async/async-whitepaper.md)

## See also

[XAsync Members](https://docs.xbox.com/zh-CN/reference/system/xasync/xasync_members.md)\
[XAsyncGetResult](https://docs.xbox.com/zh-CN/reference/system/xasyncprovider/functions/xasyncgetresult.md)\
[异步编程模型](https://docs.xbox.com/zh-CN/build/core-features/common/async/async-programming-model.md)


## Related topics

- [XAsyncGetResultSize](https://docs.xbox.com/zh-CN/reference/system/xasync/functions/xasyncgetresultsize.md)
- [PFUninitializeAsync](https://docs.xbox.com/zh-CN/services/playfab/api-references/c/pfcore/functions/pfuninitializeasync.md)
- [XAsyncCompletionRoutine](https://docs.xbox.com/zh-CN/reference/system/xasync/functions/xasynccompletionroutine.md)
- [XblAchievementsUpdateAchievementAsync](https://docs.xbox.com/zh-CN/reference/live/xsapi-c/achievements_c/functions/xblachievementsupdateachievementasync.md)
- [XblSocialSubmitReputationFeedbackAsync](https://docs.xbox.com/zh-CN/reference/live/xsapi-c/social_c/functions/xblsocialsubmitreputationfeedbackasync.md)
