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

# XAsyncGetResult

> XAsyncGetResult

# XAsyncGetResult

從非同步提供者傳回非同步呼叫的結果。

## 語法

```cpp theme={null}
HRESULT XAsyncGetResult(  
         XAsyncBlock* asyncBlock,  
         const void* identity,  
         size_t bufferSize,  
         void* buffer,  
         size_t* bufferUsed  
)  
```

### 參數

*asyncBlock*   \_Inout\_\
類型：[XAsyncBlock\*](/zh-TW/reference/system/xasync/structs/xasyncblock)

指向為非同步呼叫傳遞給 [XAsyncBegin](/zh-TW/reference/system/xasyncprovider/functions/xasyncbegin) 之 [XAsyncBlock](/zh-TW/reference/system/xasync/structs/xasyncblock) 的指標。

*identity*   \_In\_opt\_\
類型：void\*

選擇性。指向可用來識別非同步呼叫之任意權杖的指標。如果對應的 [XAsyncBegin](/zh-TW/reference/system/xasyncprovider/functions/xasyncbegin) 呼叫的 *identity* 參數有指定值，就必須在此指定相同的指標。

*bufferSize*   \_In\_\
類型：size\_t

*buffer* 中指定之結果緩衝區的大小 (以位元組為單位)。

*buffer*   \_Out\_writes\_bytes\_to\_opt\_(bufferSize, \*bufferUsed)\
類型：void\*

指向結果緩衝區的指標。

*bufferUsed*   \_Out\_opt\_\
類型：size\_t\*

選擇性。包含寫入 *buffer* 中指定之結果緩衝區的位元組數目的指標。此值定義為非同步提供者在叫用 [XAsyncComplete](/zh-TW/reference/system/xasyncprovider/functions/xasynccomplete) 時所指定之 *requiredResultSize* 參數的值。

### 傳回值

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

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

## 備註

如果非同步呼叫具有資料承載，請叫用此函式以傳回資料承載。如果非同步呼叫沒有資料承載，則不需要叫用此函式。如果對沒有資料承載的非同步呼叫叫用此函式，函式會傳回錯誤碼 `E_NOT_SUPPORTED`。

如果為此非同步呼叫的 [XAsyncBegin](/zh-TW/reference/system/xasyncprovider/functions/xasyncbegin) 函式之 *identity* 參數指定了值，則也必須為此函式的 *identity* 參數提供相同的值。否則會發生呼叫不相符的情況，且函式會傳回錯誤碼 `E_INVALIDARG`。

此函式完成且結果已傳回至 *buffer* 中指定的結果緩衝區之後，*asyncBlock* 中指定的 [XAsyncBlock](/zh-TW/reference/system/xasync/structs/xasyncblock) 即告完成，且不再與該非同步呼叫相關聯。

## 需求

**標頭：** XAsyncProvider.h

**程式庫：** xgameruntime.lib

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

## 概念文件

* [設定自訂提供者](/zh-TW/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-custom-provider)
* [設定傳回資料](/zh-TW/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-return-data)
* [非同步程式設計模型](/zh-TW/build/core-features/common/async/async-programming-model)

## 另請參閱

[XAsyncProvider 成員](/zh-TW/reference/system/xasyncprovider/xasyncprovider_members)\
[XAsyncBegin](/zh-TW/reference/system/xasyncprovider/functions/xasyncbegin)\
[XAsyncComplete](/zh-TW/reference/system/xasyncprovider/functions/xasynccomplete)\
[非同步程式設計模型](/zh-TW/build/core-features/common/async/async-programming-model)


## Related topics

- [XAsyncGetResult](/reference/system/xasyncprovider/functions/xasyncgetresult.md)
- [XAsyncGetResultSize](/reference/system/xasync/functions/xasyncgetresultsize.md)
