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

# Como: duplicar um identificador de fila de tarefas

> Como: duplicar um identificador de fila de tarefas

## Exemplo

Se você tiver um trabalho de longa duração, talvez queira duplicar o identificador da fila de tarefas durante o trabalho. Dessa forma, quem chamar `XTaskQueueCloseHandle` não fechará a fila enquanto você ainda precisar dela. Isso é mostrado no exemplo a seguir.

```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); 
    } 
} 
```

## Consulte também

[Projetando a fila de tarefas](/pt-BR/build/core-features/common/async/async-task-queue-design)


## Related topics

- [Notas de versão do SDK C++ do PlayFab Multiplayer](/pt-BR/services/playfab/multiplayer/lobby/lobby-matchmaking-sdks/lobby-and-matchmaking-release-notes.md)
- [Notas de versão do PlayFab Party](/pt-BR/services/playfab/multiplayer/networking/release-notes.md)
- [Identificadores de entidad](/es/services/playfab/sdks/c/entity-handles.md)
- [XTaskQueueDuplicateHandle](/es/reference/system/xtaskqueue/functions/xtaskqueueduplicatehandle.md)
- [Configure sua organização no Partner Center](/pt-BR/home/onboarding-access/setup-organization.md)
