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

# Microsoft Game Development Kit API 작업 실행 예제

> Microsoft Game Development Kit API 작업 실행 예제

이 항목은 Microsoft Game Development Kit(GDK) API 작업을 실행하는 방법의 예를 제공합니다. 비동기 Microsoft Game Development Kit(GDK) API 함수는 내부적으로 작업 콜백을 구현합니다. 그러나 async 블록에 지정된 작업 큐의 지시에 따라 실행됩니다. 이러한 메서드를 실행하려면 async 블록과 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;
}
```

이 코드는 [일반 작업 실행](/build/core-features/common/async/async-libraries/async-library-xasync-example-run-simple-task) 코드와 크게 다르지 않습니다. 작업 콜백과 함께 [XAsyncRun](/reference/system/xasync/functions/xasyncrun)을 사용하는 대신 사용하려는 API를 호출합니다. async 블록은 동일한 방식으로 설정됩니다. 차이점은 [XUserAddAsync](/reference/system/xuser/functions/xuseraddasync)의 경우 호출로부터 검색할 데이터가 있어서 [XUserAddResult](/reference/system/xuser/functions/xuseraddresult)를 사용하여 완료 콜백에서 이를 수행한다는 점입니다.

## 참고 API 문서

* [XAsync(API 콘텐츠)](/reference/system/xasync/xasync_members)
  * 함수
    * [XAsyncRun](/reference/system/xasync/functions/xasyncrun)
* [xuser(API 콘텐츠)](/reference/system/xuser/xuser_members)
  * 함수
    * [XUserAddAsync](/reference/system/xuser/functions/xuseraddasync)
    * [XUserAddResult](/reference/system/xuser/functions/xuseraddresult)

## 참고 항목

[XAsync 라이브러리 개요](/build/core-features/common/async/async-libraries/async-library-xasync)

[비동기 작업 설정(예제)](/build/core-features/common/async/async-libraries/async-library-xasync-example-setup-async-task)

[간단한 작업 실행(예제)](/build/core-features/common/async/async-libraries/async-library-xasync-example-run-simple-task)

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


## Related topics

- [간단한 작업 실행 예제](/ko/build/core-features/common/async/async-libraries/async-library-xasync-example-run-simple-task.md)
- [비동기 작업 설정 예제](/ko/build/core-features/common/async/async-libraries/async-library-xasync-example-setup-async-task.md)
- [비동기 작업 프로그래밍을 위한 XAsync 라이브러리](/ko/build/core-features/common/async/async-libraries/index.md)
- [방법: 프로세스 작업 큐 사용](/ko/build/core-features/common/async/async-task-queue-design-howto/using-process-task-queue.md)
- [비동기 프로그래밍 개요](/ko/build/core-features/common/async/async-toc.md)
