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

# 방법: 작업 큐 핸들 복제

> 방법: 작업 큐 핸들 복제

## 예제

오래 실행되는 작업이 있는 경우, 작업 기간 동안 작업 큐 핸들을 복제할 수 있습니다. 이렇게 하면 여전히 큐가 필요한 상태에서 누군가 `XTaskQueueCloseHandle`을 호출해도 큐가 닫히지 않습니다. 이는 다음 예에 나와 있습니다.

```c++ theme={null}
void DuplicatingTaskQueueHandle() 
{ 
    XTaskQueueHandle queue; 
 
    HRESULT hr = XTaskQueueCreate( 
        XTaskQueueDispatchMode::Manual,  
        XTaskQueueDispatchMode::Manual,  
        &queue); 
 
    if (FAILED(hr)) 
    { 
        printf("Failed to create task queue: 0x%x\r\n", hr); 
        return; 
    } 
 
    class LongRunningWork 
    { 
    public: 
        HRESULT Initialize(XTaskQueueHandle queue) 
        { 
            return XTaskQueueDuplicateHandle(queue, &m_queue); 
        } 
         
        ~LongRunningWork() 
        { 
            if (m_queue != nullptr) 
            { 
                XTaskQueueCloseHandle(m_queue); 
            } 
        } 
 
    private: 
        XTaskQueueHandle m_queue = nullptr; 
    }; 
 
    LongRunningWork work; 
    hr = work.Initialize(queue); 
     
    // Note that the queue handle for LongRunningWork is still valid. 
    XTaskQueueCloseHandle(queue); 
 
    if (FAILED(hr)) 
    { 
        printf("Failed to duplicate queue handle: 0x%x\r\n", hr); 
    } 
} 
```

## 참고 항목

[작업 큐 설계](/build/core-features/common/async/async-task-queue-design)


## Related topics

- [비동기 작업 큐 설계](/ko/build/core-features/common/async/async-task-queue-design.md)
- [방법: 작업 큐 대기자 사용](/ko/build/core-features/common/async/async-task-queue-design-howto/using-task-queue-waiter.md)
- [방법: 프로세스 작업 큐 사용](/ko/build/core-features/common/async/async-task-queue-design-howto/using-process-task-queue.md)
- [방법: 복합 작업 큐 만들기](/ko/build/core-features/common/async/async-task-queue-design-howto/creating-composite-task-queue.md)
- [방법: 수동 작업 큐 만들기](/ko/build/core-features/common/async/async-task-queue-design-howto/creating-manual-task-queue.md)
