> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XPackageInstallChunksResult

> XPackageInstallChunksResult

# XPackageInstallChunksResult

擷取 [XPackageInstallChunksAsync](https://docs.xbox.com/zh-TW/reference/system/xpackage/functions/xpackageinstallchunksasync.md) 呼叫的結果。

## 語法

```cpp theme={null}
HRESULT XPackageInstallChunksResult(  
         XAsyncBlock* asyncBlock,  
         XPackageInstallationMonitorHandle* installationMonitor  
)  
```

### 參數

*asyncBlock*   \_Inout\_\
類型：[XAsyncBlock\*](https://docs.xbox.com/zh-TW/reference/system/xasync/structs/xasyncblock.md)

傳遞給 [XPackageInstallChunksAsync](https://docs.xbox.com/zh-TW/reference/system/xpackage/functions/xpackageinstallchunksasync.md) 的 **XAsyncBlock**。

*installationMonitor*   \_Out\_\
類型：XPackageInstallationMonitorHandle\*

傳回時，包含該安裝作業的安裝監視器。

### 傳回值

類型：HRESULT

HRESULT 成功或錯誤碼。

## 備註

[XPackageInstallChunks](https://docs.xbox.com/zh-TW/reference/system/xpackage/functions/xpackageinstallchunks.md) 有非同步變體。安裝區塊時，可能會提示使用者接受下載大小。

此範例示範如何使用非同步 API 安裝 BigMaps：

```cpp theme={null}
void CALLBACK BigMapsInstallProgress(
    void* /* context */,
    XPackageInstallationMonitorHandle monitor)
{
    XPackageInstallationProgress progress;
    XPackageGetInstallationProgress(monitor, &progress);
    if (progress.completed)
    {
        printf("BigMaps Installed\n");
        XPackageCloseInstallationMonitorHandle(monitor);
    }
}

void CALLBACK BigMapsAsyncInstallComplete(XAsyncBlock* asyncBlock)
{
    XPackageInstallationMonitorHandle monitor;
    HRESULT hr = XPackageInstallChunksResult(asyncBlock, &monitor);
    delete asyncBlock;

    if (SUCCEEDED(hr))
    {
        XTaskQueueRegistrationToken token;
        if (FAILED(XPackageRegisterInstallationProgressChanged(
            monitor,
            nullptr,
            BigMapsInstallProgress, &token)))
        {
            XPackageCloseInstallationMonitorHandle(monitor);
        }
    }
}

HRESULT InstallBigMapsAsync(XTaskQueueHandle queue)
{
    char id[XPACKAGE_IDENTIFIER_MAX_LENGTH];
    HRESULT hr = XPackageGetCurrentProcessPackageIdentifier(_countof(id), id);
    if (FAILED(hr)) return hr;

    XPackageChunkSelector selector;
    selector.type = XPackageChunkSelectorType::Tag;
    selector.tag = "BigMaps";

    XAsyncBlock* asyncBlock = new (std::nothrow) XAsyncBlock{};
    asyncBlock->callback = BigMapsAsyncInstallComplete;
    asyncBlock->queue = queue;

    hr = XPackageInstallChunksAsync(
        id, 1, &selector, 1000,
        false, asyncBlock);

    if (FAILED(hr))
    {
        delete asyncBlock;
    }

    return hr;
}
```

## 需求

**標頭：** XPackage.h

**程式庫：** xgameruntime.lib

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

## 概念文件

* [非同步程式設計的設計目標與改進](https://docs.xbox.com/zh-TW/build/core-features/common/async/async-whitepaper.md)

## 另請參閱

[XPackage](https://docs.xbox.com/zh-TW/reference/system/xpackage/xpackage_members.md)\
[串流安裝和 Intelligent Delivery](https://docs.xbox.com/zh-TW/build/core-features/common/packaging/overviews/streaming_install-intelligent_delivery.md)\
[XPackageInstallChunks](https://docs.xbox.com/zh-TW/reference/system/xpackage/functions/xpackageinstallchunks.md)


## Related topics

- [非同步程式設計的設計目標與改進](https://docs.xbox.com/zh-TW/build/core-features/common/async/async-whitepaper.md)
- [XPackage (API 內容)](https://docs.xbox.com/zh-TW/reference/system/xpackage/xpackage_members.md)
- [在 Unity 專案中使用 GDK API 的 C# 包裝函式](https://docs.xbox.com/zh-TW/build/gdk-and-engines/unity/unity-api-wrappers.md)
- [XPackageInstallChunks](https://docs.xbox.com/zh-TW/reference/system/xpackage/functions/xpackageinstallchunks.md)
- [XPackageInstallChunksAsync](https://docs.xbox.com/zh-TW/reference/system/xpackage/functions/xpackageinstallchunksasync.md)
