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

# XAsyncCompletionRoutine

> XAsyncCompletionRoutine

# XAsyncCompletionRoutine

非同期呼び出しの完了コールバックを表します。

## Syntax

```cpp theme={null}
void XAsyncCompletionRoutine(  
         XAsyncBlock* asyncBlock  
)  
```

### Parameters

*asyncBlock*   \_Inout\_\
型: [XAsyncBlock\*](/reference/system/xasync/structs/xasyncblock)

完了コールバック用の [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) へのポインター。

### Return value

型: void

## Remarks

非同期呼び出しに *完了コールバック* を提供するために、`XAsyncCompletionRoutine` ポインターを必要に応じて指定できます。完了コールバックとは、非同期呼び出しの完了後に実行されるコールバック関数です。`XAsyncCompletionRoutine` ポインターは、非同期呼び出し用の [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) 構造体の `callback` メンバーに指定できます。

通常、完了コールバックは別のスレッドで非同期呼び出しの結果を処理します。完了コールバックは、非同期呼び出しが完了したときに呼び出されるコールバック関数を表します。コールバック関数は `XAsyncBlock` ポインターを受け取り、それを使用して後でコールバック関数の結果を取得します。

完了コールバックを指定した場合、[XAsyncGetStatus](/reference/system/xasync/functions/xasyncgetstatus) 関数を使用して、完了コールバックが完了したかどうかを定期的に確認できます。その後、必要に応じて [XAsyncGetResult](/reference/system/xasyncprovider/functions/xasyncgetresult) および [XAsyncGetResultSize](/reference/system/xasync/functions/xasyncgetresultsize) を使用して、完了したタスクから結果を取得します。

非同期呼び出しをキャンセルするために [XAsyncCancel](/reference/system/xasync/functions/xasynccancel) が呼び出された場合でも、完了コールバックは呼び出されます。

非同期呼び出しの結果を取得するには、[XAsyncGetStatus](/reference/system/xasync/functions/xasyncgetstatus)、または完了コールバックの `Get\*Result` メソッドを使用します。非同期呼び出しがキャンセルされた場合、これらのメソッドは `E_ABORT` を返します。`Get\*Result` メソッドを含む非同期プロバイダーの実装パターンの詳細については、[Asynchronous Programming Model](/build/core-features/common/async/async-programming-model) を参照してください。

## Requirements

**ヘッダー:** XAsync.h

**ライブラリ:** xgameruntime.lib

**サポートされているプラットフォーム:** Windows、XBOX One ファミリー本体および XBOX Series 本体

## Conceptual documentation

* [Asynchronous Programming Model](/build/core-features/common/async/async-programming-model)

## See also

[XAsync Members](/reference/system/xasync/xasync_members)\
[XAsyncGetStatus](/reference/system/xasync/functions/xasyncgetstatus)\
[Asynchronous Programming Model](/build/core-features/common/async/async-programming-model)


## Related topics

- [XAsyncCancel](/ja-jp/reference/system/xasync/functions/xasynccancel.md)
- [非同期プログラミング モデル](/ja-jp/build/core-features/common/async/async-programming-model.md)
- [XAsync](/ja-jp/reference/system/xasync/xasync_members.md)
- [XAsyncBlock](/ja-jp/reference/system/xasync/structs/xasyncblock.md)
- [XMEMALLOC_ROUTINE callback](/ja-jp/reference/system/xmem/functions/xmemalloc_routine.md)
