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

# 方法: コールバックの送信

> 方法: コールバックの送信

## 例

次の例は、タスク キューのワーク ポートまたは完了ポートにコールバックを送信する方法を示しています。まずワーク コールバックを送信します。次に、ワーク コールバックの最後で完了コールバックを送信します。これは典型的な使用パターンです。以降のシナリオでは、簡潔さのため `SubmitCallbacks` 関数を使用します。

```c++ theme={null}
void CALLBACK SampleCompletionCallback(void*, bool cancel)
{
    printf("Completion invoked on thread %d. Cancel? %d.\r\n",
    GetCurrentThreadId(), cancel);
}

void CALLBACK SampleWorkCallback(void* context, bool cancel)
{
    printf("Worker invoked on thread %d. Cancel? %d.\r\n",
    GetCurrentThreadId(), cancel);

    XTaskQueueHandle queueFromContext = static_cast<XTaskQueueHandle>(context);

    HRESULT hrCompletion = XTaskQueueSubmitCallback(
        queueFromContext,
        XTaskQueuePort::Completion,
        nullptr,
        SampleCompletionCallback);

    if (FAILED(hrCompletion))
    {
        printf("Error 0x%x submitting completion.\r\n", hrCompletion);
    }
}

void SubmitCallbacks(XTaskQueueHandle queue)
{
    HRESULT hrWork = XTaskQueueSubmitCallback(
        queue,
        XTaskQueuePort::Work,
        queue,
        SampleWorkCallback);

    if (FAILED(hrWork))
    {
        printf("Error 0x%x submitting work.\r\n", hrWork);
    }
}
```

## 関連項目

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


## Related topics

- [方法: 遅延コールバックの使用](/ja-jp/build/core-features/common/async/async-task-queue-design-howto/using-delayed-callbacks.md)
- [GameInput コールバック](/ja-jp/build/core-features/common/input/advanced/input-callbacks.md)
- [タイトルからのレピュテーション フィードバックの送信](/ja-jp/services/xbox-services/community/reputation/concepts/live-sending-reputation-feedback.md)
- [Game Saves の UI コールバック](/ja-jp/services/playfab/player-progression/game-saves/ui-callbacks.md)
- [レピュテーション フィードバックの送信](/ja-jp/services/xbox-services/community/reputation/how-to/live-submitting-reputation-feedback.md)
