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

# 設定叫用方法範例

> 設定叫用方法範例

本主題提供如何為自訂提供者設定叫用方法的範例。使用自訂非同步提供者時，最好使用叫用
方法，讓提供者可以視需要重複使用。

```c++ theme={null}
HRESULT CustomProviderMethodAsync(XAsyncBlock* async)
{
    // Set up the context for your method.
    void* context;
    HRESULT hr = XAsyncBegin(async, context, CustomProviderMethodAsync, __FUNCTION__,
        [](XAsyncOp op, const XAsyncProviderData* providerData)
        {
            // Provider cases are handled here.
            return S_OK;
        });
    return hr;
}
```

此範例示範所有非同步 Microsoft Game Development Kit (GDK) 方法的實作方式，並
允許重複使用提供者。如果 `DoWork` 案例非常
特定，它就會成為特殊化的非同步函式。若要使其
通用，請允許以某種方式自訂 `DoWork` 案例。

## 參考 API 文件

* [XAsyncProvider (API 內容)](/zh-TW/reference/system/xasyncprovider/xasyncprovider_members)

## 另請參閱

[XAsyncProvider 程式庫概觀](/zh-TW/build/core-features/common/async/async-libraries/async-library-xasyncprovider)

[設定自訂提供者 (範例)](/zh-TW/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-custom-provider)

[設定傳回資料 (範例)](/zh-TW/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-return-data)

[設定可取消性 (範例)](/zh-TW/build/core-features/common/async/async-libraries/async-library-xasyncprovider-example-setup-cancelability)

[XAsyncProvider](/zh-TW/reference/system/xasyncprovider/xasyncprovider_members)


## Related topics

- [GDK 範例](/zh-TW/home/setup-install/samples.md)
- [XBOX 主機遊戲的認證測試 XBOX 需求](/zh-TW/publishing/certification/console-cert-tested-requirements.md)
- [XR-045 XBOX 網路與帳戶權限](/zh-TW/publishing/certification/xr/xr-045.md)
- [XBOX Services API (XSAPI) の使用方法](/ja-jp/services/xbox-services/fundamentals/xbox-services-api/live-gs-xbl-apis.md)
- [XBOX PC Remote Tools の使用方法](/ja-jp/tools/tools-pc/xbox-pc-remote-tools/how-to-use-tools.md)
