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

# 비동기 작업 설정 예제

> 비동기 작업 설정 예제

이 항목은 비동기 작업을 설정하는 방법의 예를 제공합니다. 실행할 비동기 작업을 위해 [XAsyncBlock](/reference/system/xasync/structs/xasyncblock)을 설정하세요. 이러한 async 블록은 여러 활성 비동기 작업 간에 공유할 수 없습니다. 그러나 원본 작업이 완료된 후에는 다른 작업에 다시 사용할 수 있습니다. 간단한 패턴은 각 호출마다 블록을 동적으로 할당한 다음, 호출이 완료 콜백에서 종료될 때 해제하는 것입니다.

```c++ theme={null}
XAsyncBlock* async = new XAsyncBlock{};
async->queue = taskQueue;
async->context = contextData;
async->callback = 
    [](XAsyncBlock* async)
    {
        // The optional completion callback.
        delete async;
    }
```

완료 콜백의 매개 변수는 이전에 만들어진 async 블록입니다. 이를 통해 컨텍스트에 접근하고 원하는 대로 입력 및 출력으로 사용할 적절한 형식으로 캐스팅할 수 있습니다.

## 참고 API 문서

* [XAsync(API 콘텐츠)](/reference/system/xasync/xasync_members)
  * 구조체
    * [XAsyncBlock](/reference/system/xasync/structs/xasyncblock)

## 참고 항목

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

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

[Microsoft Game Development Kit(GDK) API 작업 실행(예제)](/build/core-features/common/async/async-libraries/async-library-xasync-example-run-gdk-task)

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


## Related topics

- [비동기 작업 프로그래밍을 위한 XAsync 라이브러리](/ko/build/core-features/common/async/async-libraries/index.md)
- [간단한 작업 실행 예제](/ko/build/core-features/common/async/async-libraries/async-library-xasync-example-run-simple-task.md)
- [Microsoft Game Development Kit API 작업 실행 예제](/ko/build/core-features/common/async/async-libraries/async-library-xasync-example-run-gdk-task.md)
- [비동기 작업 큐 설계](/ko/build/core-features/common/async/async-task-queue-design.md)
- [일반 비동기 작업 래퍼](/ko/build/core-features/common/async/async-task-function-example.md)
