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

# Set up invocation methods

> Wrap XAsyncBegin and its provider callback in a reusable method, the same pattern used by async GDK functions, and keep the DoWork case generic.

This topic provides an example of how to set up invocation methods for a custom provider. When working with custom async providers, it's best to use invocation
methods so that the provider can be reused as needed.

```c++ theme={null}
HRESULT CustomProviderMethodAsync(XAsyncBlock* async)
{
    // Set up the context for your method.
    void* context;
    HRESULT hr = XAsyncBegin(async, context, CustomProviderMethodAsync, __FUNCTION__,
        [](XAsyncOp op, const XAsyncProviderData* providerData)
        {
            // Provider cases are handled here.
            return S_OK;
        });
    return hr;
}
```

This example shows how all asynchronous Microsoft Game Development Kit (GDK) methods are implemented and
allows for reuse of the provider. If the `DoWork` case is highly
specific, it becomes a specialized asynchronous function. To make
it generic, allow the `DoWork` case to be customized in some way.

## Reference API documentation

* [XAsyncProvider (API contents)](https://docs.xbox.com/reference/system/xasyncprovider/xasyncprovider_members.md)

## See also

[XAsyncProvider library overview](https://docs.xbox.com/build/core-features/common/async/async-libraries/async-library-xasyncprovider.md)

[Set up custom provider (example)](https://docs.xbox.com/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-custom-provider.md)

[Set up return data (example)](https://docs.xbox.com/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-return-data.md)

[Set up cancelability (example)](https://docs.xbox.com/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-cancelability.md)

[XAsyncProvider](https://docs.xbox.com/reference/system/xasyncprovider/xasyncprovider_members.md)


## Related topics

- [Set up cancelability](https://docs.xbox.com/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-cancelability.md)
- [Set up custom provider](https://docs.xbox.com/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-custom-provider.md)
- [XAsyncProvider library overview](https://docs.xbox.com/build/core-features/common/async/async-libraries/async-library-xasyncprovider.md)
- [XAsync libraries for asynchronous task programming](https://docs.xbox.com/build/core-features/common/async/async-libraries/index.md)
- [Set up return data](https://docs.xbox.com/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-return-data.md)
