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

# XAsyncGetStatus

> XAsyncGetStatus

# XAsyncGetStatus

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

## Syntax

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

### Parameters

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

指向传递给异步调用的 [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) 的指针。

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

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

### Return value

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

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

## Remarks

异步调用完成后，如果该异步调用具有结果数据负载，则可以调用 [XAsyncGetResult](/reference/system/xasyncprovider/functions/xasyncgetresult) 来获取结果。如果异步调用没有结果数据负载，则无需调用 [XAsyncGetResult](/reference/system/xasyncprovider/functions/xasyncgetresult)。

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

## Requirements

**头文件：** XAsync.h

**库：** xgameruntime.lib

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

## Conceptual documentation

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

## See also

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


## Related topics

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