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

# XPackageInstallChunksResult

> XPackageInstallChunksResult

# XPackageInstallChunksResult

擷取 [XPackageInstallChunksAsync](/zh-TW/reference/system/xpackage/functions/xpackageinstallchunksasync) 呼叫的結果。

## 語法

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

### 參數

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

傳遞給 [XPackageInstallChunksAsync](/zh-TW/reference/system/xpackage/functions/xpackageinstallchunksasync) 的 **XAsyncBlock**。

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

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

### 傳回值

類型：HRESULT

HRESULT 成功或錯誤碼。

## 備註

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

此範例示範如何使用非同步 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 主機

## 概念文件

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

## 另請參閱

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


## Related topics

- [XPackageInstallChunksResult](/reference/system/xpackage/functions/xpackageinstallchunksresult.md)
- [XPackage](/reference/system/xpackage/xpackage_members.md)
- [Asynchronous programming design goals and improvements](/build/core-features/common/async/async-whitepaper.md)
