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

# Run Microsoft Game Development Kit API task example

> Run Microsoft Game Development Kit API task example

This topic provides an example of how to run a Microsoft Game Development Kit (GDK) API task. Async Microsoft Game Development Kit (GDK) API functions internally implement the work callback. However, it still runs as directed by the task queue as specified in the
async block. Running these methods requires the async block and
whatever parameters are needed for the API.

```c++ theme={null}
// Set up the async block and completion callback.
XAsyncBlock* async = new XAsyncBlock{};
async->queue = taskQueue;
async->context = nullptr;
async->callback = [](XAsyncBlock* async)
{
    XUserHandle newUser = nullptr;
    HRESULT result = XUserAddResult(async, &newUser);
    // Handle the completion callback.
    delete async;
};

// Start the async call.
HRESULT hr = XUserAddAsync(XUserAddOptions::None, async);
if (FAILED(hr))
{
    delete async;
}
```

This code doesn't differ much from the code to [run generic tasks](/build/core-features/common/async/async-libraries/async-library-xasync-example-run-simple-task).
Instead of using [XAsyncRun](/reference/system/xasync/functions/xasyncrun) with a work callback, you call
into the API that you want to use. The async block is set up
in the same way. The difference there is that [XUserAddAsync](/reference/system/xuser/functions/xuseraddasync)
has data to be retrieved from the call that's done in the
completion callback with [XUserAddResult](/reference/system/xuser/functions/xuseraddresult).

## Reference API documentation

* [XAsync (API contents)](/reference/system/xasync/xasync_members)
  * Functions
    * [XAsyncRun](/reference/system/xasync/functions/xasyncrun)
* [xuser (API contents)](/reference/system/xuser/xuser_members)
  * Functions
    * [XUserAddAsync](/reference/system/xuser/functions/xuseraddasync)
    * [XUserAddResult](/reference/system/xuser/functions/xuseraddresult)

## See also

[XAsync library overview](/build/core-features/common/async/async-libraries/async-library-xasync)

[Set up async task (example)](/build/core-features/common/async/async-libraries/async-library-xasync-example-setup-async-task)

[Run simple task (example)](/build/core-features/common/async/async-libraries/async-library-xasync-example-run-simple-task)

[XAsync](/reference/system/xasync/xasync_members)


## Related topics

- [Run simple task example](/build/core-features/common/async/async-libraries/async-library-xasync-example-run-simple-task.md)
- [Set up async task example](/build/core-features/common/async/async-libraries/async-library-xasync-example-setup-async-task.md)
- [XAsync libraries for asynchronous task programming](/build/core-features/common/async/async-libraries/index.md)
- [XAsyncRun](/reference/system/xasync/functions/xasyncrun.md)
- [How to: Using the process task queue](/build/core-features/common/async/async-task-queue-design-howto/using-process-task-queue.md)
