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

# XAsyncCancel

> XAsyncCancel

# XAsyncCancel

嘗試取消非同步呼叫。

## 語法

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

### 參數

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

非同步呼叫之 [XAsyncBlock](/zh-TW/reference/system/xasync/structs/xasyncblock) 的指標。

### 傳回值

類型：void

## 備註

如果針對尚未完成的非同步呼叫叫用 `XAsyncCancel` 函式，[XAsyncGetResult](/zh-TW/reference/system/xasyncprovider/functions/xasyncgetresult)、[XAsyncGetResultSize](/zh-TW/reference/system/xasync/functions/xasyncgetresultsize) 和 [XAsyncGetStatus](/zh-TW/reference/system/xasync/functions/xasyncgetstatus) 函式會傳回 `E_ABORT`，並發出非同步呼叫完成的訊號。視要取消的呼叫而定，取消可能會同步發生、非同步發生，或完全不會發生。如果已為非同步呼叫指定完成回呼，則會接著叫用該回呼。如需完成回呼的詳細資訊，請參閱 [XAsyncCompletionRoutine](/zh-TW/reference/system/xasync/functions/xasynccompletionroutine)。

如果針對已經完成的非同步呼叫叫用 `XAsyncCancel` 函式，則不會發生任何事。

## 需求

**標頭：** XAsync.h

**程式庫：** xgameruntime.lib

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

## 概念文件

* [XAsync 程式庫概觀](/zh-TW/build/core-features/common/async/async-libraries/async-library-xasync)
* [設定可取消性](/zh-TW/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-cancelability)
* [設定自訂提供者](/zh-TW/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-custom-provider)
* [非同步程式設計模型](/zh-TW/build/core-features/common/async/async-programming-model)

## 另請參閱

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


## Related topics

- [XAsyncCancel](/reference/system/xasync/functions/xasynccancel.md)
- [Set up cancelability example](/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-cancelability.md)
- [Ejemplo de configuración de la capacidad de cancelación](/es/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-cancelability.md)
- [XAsync](/reference/system/xasync/xasync_members.md)
- [设置可取消性示例](/zh-CN/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-cancelability.md)
