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

# XAsyncComplete

> XAsyncComplete

# XAsyncComplete

Indicates that the callback function for an asynchronous provider has completed work and the results can be returned.

## Syntax

```cpp theme={null}
void XAsyncComplete(  
         XAsyncBlock* asyncBlock,  
         HRESULT result,  
         size_t requiredBufferSize  
)  
```

### Parameters

*asyncBlock*   \_Inout\_\
Type: [XAsyncBlock\*](/reference/system/xasync/structs/xasyncblock)

A pointer to the [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) that was passed to [XAsyncBegin](/reference/system/xasyncprovider/functions/xasyncbegin).

*result*   \_In\_\
Type: [HRESULT](https://learn.microsoft.com/openspecs/windows_protocols/ms-erref/0642cb2f-2075-4469-918c-4441e69c548a)

The result of the work performed by the callback function. If the work is canceled, set this to `E_ABORT`. If more work needs to be done, set this to `E_PENDING`. Otherwise, set this to the appropriate result code.

*requiredBufferSize*   \_In\_\
Type: size\_t

The required size, in bytes, of the data payload to be returned by the callback function. If the callback function doesn't return a data payload, set this value to zero. This parameter is ignored if the callback function returns an error.

### Return value

Type: void

## Remarks

<Note>This function isn't safe to call on a time-sensitive thread. For more information, see [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads).</Note>

This function is called when the callback function has been called to either perform or cancel asynchronous work. The function returns an appropriate result code and, if applicable, information about the data payload. The combination of [XAsyncOp](/reference/system/xasyncprovider/enums/xasyncop) operation code, asynchronous work, and data payload for the callback function typically determines the values that should be provided for *result* and *requiredBufferSize* when calling this function.

If the callback function has been called with the `XAsyncOp::DoWork` operation code, the callback function should perform asynchronous work. If the callback function has completed all asynchronous work, set *result* to an appropriate error code. If more work needs to be done, set *result* to `E_PENDING`. If the function returns a data payload, set *requiredBufferSize* to the size, in bytes, of the buffer needed to return the data payload; otherwise, set *requiredBufferSize* to zero.

If the callback function has been called with the `XAsyncOp::Cancel` operation code, the callback function should cancel asynchronous work. Set *result* to `E_ABORT` and *requiredBufferSize* to zero.

## Requirements

**Header:** XAsyncProvider.h

**Library:** xgameruntime.lib

**Supported platforms:** Windows, XBOX One family consoles and XBOX Series consoles

## Conceptual documentation

* [Set up cancelability](/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-cancelability)
* [Set up custom provider](/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-custom-provider)
* [Set up return data](/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-return-data)
* [Asynchronous Programming Model](/build/core-features/common/async/async-programming-model)
* [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## See also

[XAsyncProvider Members](/reference/system/xasyncprovider/xasyncprovider_members)\
[XAsyncBegin](/reference/system/xasyncprovider/functions/xasyncbegin)\
[Asynchronous Programming Model](/build/core-features/common/async/async-programming-model)


## Related topics

- [XAsyncOp](/reference/system/xasyncprovider/enums/xasyncop.md)
- [XAsyncGetResult](/reference/system/xasyncprovider/functions/xasyncgetresult.md)
- [AsyncProviderData](/reference/system/xasyncprovider/structs/xasyncproviderdata.md)
- [Asynchronous Programming Model](/build/core-features/common/async/async-programming-model.md)
- [Set up return data example](/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-return-data.md)
