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

返回来自异步提供程序的异步调用的结果。

## Syntax

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

### Parameters

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

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

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

可选。指向可用于标识异步调用的任意标记的指针。如果为对应的 [XAsyncBegin](/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](/reference/system/xasyncprovider/functions/xasynccomplete) 时指定的 *requiredResultSize* 参数的值。

### Return value

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

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

## Remarks

如果异步调用具有数据负载，请调用此函数以返回数据负载。如果异步调用没有数据负载，则不需要调用此函数。如果对没有数据负载的异步调用调用此函数，则该函数将返回错误代码 `E_NOT_SUPPORTED`。

如果为此异步调用的 [XAsyncBegin](/reference/system/xasyncprovider/functions/xasyncbegin) 函数的 *identity* 参数指定了一个值，则必须为此函数的 *identity* 参数也提供相同的值。否则会发生调用不匹配，并且函数将返回错误代码 `E_INVALIDARG`。

此函数完成且结果在 *buffer* 中指定的结果缓冲区中返回后，*asyncBlock* 中指定的 [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) 将完成，不再与异步调用关联。

## Requirements

**头文件：** XAsyncProvider.h

**库：** xgameruntime.lib

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

## Conceptual documentation

* [设置自定义提供程序](/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-custom-provider)
* [设置返回数据](/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-return-data)
* [异步编程模型](/build/core-features/common/async/async-programming-model)

## See also

[XAsyncProvider Members](/reference/system/xasyncprovider/xasyncprovider_members)\
[XAsyncBegin](/reference/system/xasyncprovider/functions/xasyncbegin)\
[XAsyncComplete](/reference/system/xasyncprovider/functions/xasynccomplete)\
[异步编程模型](/build/core-features/common/async/async-programming-model)


## Related topics

- [XAsyncGetResultSize](/zh-CN/reference/system/xasync/functions/xasyncgetresultsize.md)
- [XAsyncGetStatus](/zh-CN/reference/system/xasync/functions/xasyncgetstatus.md)
- [XAsyncBegin](/zh-CN/reference/system/xasyncprovider/functions/xasyncbegin.md)
- [设置返回数据示例](/zh-CN/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-return-data.md)
- [XAsync](/zh-CN/reference/system/xasync/xasync_members.md)
