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

# 方法: スレッド プール タスク キューの作成

> 方法: スレッド プール タスク キューの作成

## 例

次の例は、ワーク コールバックと完了コールバックの両方をシステム スレッド プールでディスパッチするタスク キューを作成する方法を示しています。

```c++ theme={null}
void CreatingTaskQueue()  
{  
    XTaskQueueHandle queue;  
 
    HRESULT hr = XTaskQueueCreate(  
        XTaskQueueDispatchMode::ThreadPool,  
        XTaskQueueDispatchMode::ThreadPool,  
        &queue);  
 
    if (FAILED(hr))  
    { 
        printf("Creating queue failed: 0x%x\r\n", hr);  
        return;  
    }  
 
    SubmitCallbacks(queue); 
 
    // Wait a while for the callbacks to run.  
    Sleep(1000);  
 
    XTaskQueueTerminate(queue, true, nullptr, nullptr);  
}  
```

## サンプル出力

```
Worker invoked on thread 11440. Cancel? 0. 
Completion invoked on thread 11440. Cancel? 0.  
```

## 関連項目

[タスク キューの設計](/build/core-features/common/async/async-task-queue-design)


## Related topics

- [方法: 複合タスク キューの作成](/ja-jp/build/core-features/common/async/async-task-queue-design-howto/creating-composite-task-queue.md)
- [方法: 手動タスク キューの作成](/ja-jp/build/core-features/common/async/async-task-queue-design-howto/creating-manual-task-queue.md)
- [タスク キューの作成例](/ja-jp/build/core-features/common/async/async-libraries/async-library-xtaskqueue-example-create-task-queue.md)
- [非同期タスク キューの設計](/ja-jp/build/core-features/common/async/async-task-queue-design.md)
- [XTaskQueueDispatchMode](/ja-jp/reference/system/xtaskqueue/enums/xtaskqueuedispatchmode.md)
