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

# XAsyncWork

> XAsyncWork

# XAsyncWork

代表由 [XAsyncRun](/zh-TW/reference/system/xasync/functions/xasyncrun) 叫用的回呼函式。

## 語法

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

### 參數

*asyncBlock*   \_Inout\_\
類型：[XAsyncBlock\*](/zh-TW/reference/system/xasync/structs/xasyncblock)

指向傳遞給 [XAsyncRun](/zh-TW/reference/system/xasync/functions/xasyncrun) 之 [XAsyncBlock](/zh-TW/reference/system/xasync/structs/xasyncblock) 複本的指標。

### 傳回值

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

如果成功，則傳回 `S_OK`；否則傳回錯誤碼。如需錯誤碼清單，請參閱[錯誤碼](/zh-TW/reference/errorcodes)。

## 備註

使用指向傳遞給 [XAsyncRun](/zh-TW/reference/system/xasync/functions/xasyncrun) 之 [XAsyncBlock](/zh-TW/reference/system/xasync/structs/xasyncblock) 複本的指標，可讓系統確保該指標對回呼而言一律存在且有效。

使用 [XAsyncRun](/zh-TW/reference/system/xasync/functions/xasyncrun) 協助程式函式以非同步方式執行回呼函式時，您需為要叫用的回呼函式指定 `XAsyncWork` 指標。接著 `XAsyncRun` 會使用 [XAsyncProvider](/zh-TW/reference/system/xasyncprovider/xasyncprovider_members) 功能來執行回呼函式。

如需 `XAsyncProvider` 功能的詳細資訊，請參閱[非同步程式設計模型](/zh-TW/build/core-features/common/async/async-programming-model)。

## 需求

**標頭：** XAsync.h

**程式庫：** xgameruntime.lib

**支援的平台：** Windows、XBOX One 系列主機和 XBOX Series 主機

## 另請參閱

[XAsync 成員](/zh-TW/reference/system/xasync/xasync_members)\
[XAsyncRun](/zh-TW/reference/system/xasync/functions/xasyncrun)\
[非同步程式設計模型](/zh-TW/build/core-features/common/async/async-programming-model)


## Related topics

- [XAsyncWork](/reference/system/xasync/functions/xasyncwork.md)
- [XAsyncRun](/reference/system/xasync/functions/xasyncrun.md)
