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

# XAsyncRun

> XAsyncRun

# XAsyncRun

指定されたコールバック関数を非同期に実行します。

## Syntax

```cpp theme={null}
HRESULT XAsyncRun(  
         XAsyncBlock* asyncBlock,  
         XAsyncWork* work  
)  
```

### Parameters

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

非同期呼び出しを追跡するために使用される [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) へのポインター。

*work*   \_In\_\
型: [XAsyncWork\*](/reference/system/xasync/functions/xasyncwork)

非同期に実行するコールバック関数へのポインター。

### Return value

型: [HRESULT](https://learn.microsoft.com/openspecs/windows_protocols/ms-erref/0642cb2f-2075-4469-918c-4441e69c548a)

成功した場合は `S_OK` を返します。それ以外の場合はエラー コードを返します。エラー コードの一覧については、[Error Codes](/reference/errorcodes) を参照してください。

## Remarks

`XAsyncRun` は、*work* に指定されたコールバック関数を非同期に実行するヘルパー関数です。*asyncBlock* に指定された `XAsyncBlock` を使用して、コールバック関数のキャンセルまたは状態の取得を行うことができます。`XAsyncRun` は内部的に、以下の `XAsyncProvider` 関数を使用してコールバック関数を実行および追跡します:

* [XAsyncBegin](/reference/system/xasyncprovider/functions/xasyncbegin)
* [XAsyncComplete](/reference/system/xasyncprovider/functions/xasynccomplete)
* [XAsyncSchedule](/reference/system/xasyncprovider/functions/xasyncschedule)

`XAsyncProvider` および `XAsyncBlock` を使用して独自の非同期機能を実装する方法の詳細については、[Asynchronous Programming Model](/build/core-features/common/async/async-programming-model) を参照してください。

## Requirements

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

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

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

## Conceptual documentation

* [Run Microsoft Game Development Kit (GDK) API task](/build/core-features/common/async/async-libraries/async-library-xasync-example-run-gdk-task)
* [Run simple task](/build/core-features/common/async/async-libraries/async-library-xasync-example-run-simple-task)
* [XAsync library overview](/build/core-features/common/async/async-libraries/async-library-xasync)
* [Set up cancelability](/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-cancelability)
* [Set up custom provider](/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-custom-provider)
* [Asynchronous Programming Model](/build/core-features/common/async/async-programming-model)
* [Generic async task wrapper](/build/core-features/common/async/async-task-function-example)

## See also

[XAsync Members](/reference/system/xasync/xasync_members)\
[XAsyncProvider Members](/reference/system/xasyncprovider/xasyncprovider_members)\
[Asynchronous Programming Model](/build/core-features/common/async/async-programming-model)


## Related topics

- [XAsyncWork](/ja-jp/reference/system/xasync/functions/xasyncwork.md)
- [XAsync](/ja-jp/reference/system/xasync/xasync_members.md)
- [単純なタスクの実行例](/ja-jp/build/core-features/common/async/async-libraries/async-library-xasync-example-run-simple-task.md)
- [XNetworkingQueryPreferredLocalUdpMultiplayerPortAsync](/ja-jp/reference/networking/xnetworking/functions/xnetworkingquerypreferredlocaludpmultiplayerportasync.md)
- [汎用非同期タスク ラッパー](/ja-jp/build/core-features/common/async/async-task-function-example.md)
