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

# XPackageChangeChunkInstallOrder

> XPackageChangeChunkInstallOrder

# XPackageChangeChunkInstallOrder

Specifies which selected chunks are to be installed first.

## Syntax

```cpp theme={null}
HRESULT XPackageChangeChunkInstallOrder(  
        const char* packageIdentifier,  
        uint32_t selectorCount,  
        XPackageChunkSelector* selectors
)  
```

### Parameters

*packageIdentifier*   \_In\_z\_\
Type: char\*

A string that uniquely identifies the installed package on the disk.  For more information about package identifiers, see [Manage and license downloadable content (DLC)](/publishing/xstore-commerce/xstore-dlc).

*selectorCount*   \_In\_\
Type: uint32\_t

The number of selectors in the *selectors* parameter.

*selectors*   \_In\_reads\_(selectorCount)\
Type: [XPackageChunkSelector\*](/reference/system/xpackage/structs/xpackagechunkselector)

An array of selectors that specifies the type of chunks to be affected.

### Return value

Type: HRESULT

HRESULT success or error code.

## Remarks

<Note>This function isn't safe to call on a time-sensitive thread. For more information, see [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads).</Note>

**XPackageChangeChunkInstallOrder** updates the chunks selected by the specified selector to be placed first in the installation queue. This can take a selector, not just an array of chunk IDs. You can pass more complex selectors here, and the chunks that make them up will all be pushed to the front of the queue.

You can call **XPackageChangeChunkInstallOrder** at any time, not only when the chunks are not installed. If the chunks are already installed, **XPackageChangeChunkInstallOrder** ignores them. The same is true when you provide chunks that, due to intelligent delivery, are not scheduled to be installed at all.

In the following example, to keep the user playing, the game must access a file called "soon". Function PrioritizeChunk is defined and checks the chunk's current installation status. If the chunk is not already installed, the function asks the streaming system to install it and returns an installation monitor that can monitor the chunk's progress. If the chunk is already installed, the function returns a null monitor.

```cpp theme={null}
HRESULT PrioritizeChunk( 
    XTaskQueueHandle queue, uint32_t chunkId, XPackageInstallationMonitorHandle* monitor) 
{ 
    char id[XPACKAGE_IDENTIFIER_MAX_LENGTH]; 
 
    *monitor = nullptr; 
    HRESULT hr = XPackageGetCurrentProcessPackageIdentifier(_countof(id), id); 
    if (FAILED(hr)) return hr; 
 
    XPackageChunkSelector selector; 
    selector.type = XPackageChunkSelectorType::Chunk; 
    selector.chunkId = chunkId; 
 
    hr = XPackageCreateInstallationMonitor(id, 1, &selector, 1000, queue, monitor); 
 
    if (SUCCEEDED(hr)) 
    { 
        XPackageInstallationProgress progress; 
        XPackageGetInstallationProgress(*monitor, &progress); 
    }

    if (!progress.completed) 
    { 
        hr = XPackageChangeChunkInstallOrder(id, 1, &selector); 
    } 
 
    if (progress.completed || FAILED(hr)) 
    { 
        XPackageCloseInstallationMonitorHandle(*monitor); 
        *monitor = nullptr; 
    } 
 
    return hr; 
} 
```

## Requirements

**Header:** XPackage.h

**Library:** xgameruntime.lib

**Supported platforms:** Windows, XBOX One family consoles and XBOX Series consoles

## Conceptual documentation

* [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## See also

[XPackage](/reference/system/xpackage/xpackage_members)\
[Streaming Installation and Intelligent Delivery](/build/core-features/common/packaging/overviews/streaming_install-intelligent_delivery)


## Related topics

- [XPackage](/reference/system/xpackage/xpackage_members.md)
- [Dynamic reordering of chunks](/build/core-features/common/packaging/packaging-chunkreordering.md)
- [Streaming Installation and Intelligent Delivery: an overview](/build/core-features/common/packaging/overviews/streaming_install-intelligent_delivery.md)
- [XPackageInstallChunks](/reference/system/xpackage/functions/xpackageinstallchunks.md)
- [<Chunk> element](/build/core-features/common/packaging/deployment/deployment-element-chunk.md)
