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

傳回非同步呼叫的狀態，並可選擇等候其完成。

## 語法

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

### 參數

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

指向傳遞給非同步呼叫之 [XAsyncBlock](https://docs.xbox.com/zh-TW/reference/system/xasync/structs/xasyncblock.md) 的指標。

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

若為 true，`XAsyncGetStatus` 會等候直到非同步呼叫完成或被取消為止。

### 傳回值

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

如果成功，則傳回 `S_OK`；否則傳回錯誤碼。如需錯誤碼清單，請參閱[錯誤碼](https://docs.xbox.com/zh-TW/reference/errorcodes.md)。

## 備註

非同步呼叫完成後，如果該非同步呼叫具有產生的資料承載，您就可以呼叫 [XAsyncGetResult](https://docs.xbox.com/zh-TW/reference/system/xasyncprovider/functions/xasyncgetresult.md) 來取得結果。如果非同步呼叫沒有產生的資料承載，則不需要呼叫 [XAsyncGetResult](https://docs.xbox.com/zh-TW/reference/system/xasyncprovider/functions/xasyncgetresult.md)。

**注意：** 完成回呼以及 wait 參數為 true 的 `XAsyncGetStatus` 都可用來識別呼叫何時完成。這些呼叫的順序可能不明確，因此最佳做法是不要對同一個呼叫同時使用兩者。

## 需求

**標頭：** XAsync.h

**程式庫：** xgameruntime.lib

**支援的平台：** Windows、XBOX One 系列主機和 XBOX Series 主機

## 概念文件

* [執行簡單工作](https://docs.xbox.com/zh-TW/build/core-features/common/async/async-libraries/async-library-xasync-example-run-simple-task.md)
* [XAsync 程式庫概觀](https://docs.xbox.com/zh-TW/build/core-features/common/async/async-libraries/async-library-xasync.md)
* [設定自訂提供者](https://docs.xbox.com/zh-TW/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-custom-provider.md)
* [非同步程式設計模型](https://docs.xbox.com/zh-TW/build/core-features/common/async/async-programming-model.md)
* [非同步程式設計的設計目標與改進](https://docs.xbox.com/zh-TW/build/core-features/common/async/async-whitepaper.md)

## 另請參閱

[XAsync 成員](https://docs.xbox.com/zh-TW/reference/system/xasync/xasync_members.md)\
[XAsyncGetResult](https://docs.xbox.com/zh-TW/reference/system/xasyncprovider/functions/xasyncgetresult.md)\
[非同步程式設計模型](https://docs.xbox.com/zh-TW/build/core-features/common/async/async-programming-model.md)


## Related topics

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