XPackageInstallChunksResult

检索对 XPackageInstallChunksAsync 的调用的结果。

语法

HRESULT XPackageInstallChunksResult(  
         XAsyncBlock* asyncBlock,  
         XPackageInstallationMonitorHandle* installationMonitor  
)  

参数

asyncBlock _Inout_
类型:XAsyncBlock*

传递到 XPackageInstallChunksAsyncXAsyncBlock

installationMonitor _Out_
类型:XPackageInstallationMonitorHandle*

在返回时,包含用于安装的安装监视器。

返回值

类型:HRESULT

HRESULT 成功或错误代码。

备注

XPackageInstallChunks 具有一个异步变体。 安装区块可能涉及提示用户接受下载大小。

此示例演示如何使用异步 API 安装 BigMaps:

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 主机

另请参阅

XPackage
流式安装和智能交付
XPackageInstallChunks