Share via


StorageLibraryChangeTrackerOptions Class

Definition

Allows callers to call EnableWithOptions on the change tracker to choose to track all changes including last change id, or just the last change id.

public ref class StorageLibraryChangeTrackerOptions sealed
/// [Windows.Foundation.Metadata.Activatable(720896, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 720896)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class StorageLibraryChangeTrackerOptions final
[Windows.Foundation.Metadata.Activatable(720896, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 720896)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class StorageLibraryChangeTrackerOptions
function StorageLibraryChangeTrackerOptions()
Public NotInheritable Class StorageLibraryChangeTrackerOptions
Inheritance
Object Platform::Object IInspectable StorageLibraryChangeTrackerOptions
Attributes

Windows requirements

Device family
Windows 10, version 2104 (introduced in 10.0.20348.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v12.0)

Examples

// applications are expected to persist the previous value
UINT64 appsLastPersistedChangeId = StorageLibraryLastChangeId::Unknown();
StorageFolder folder = StorageFolder::GetFolderFromPathAsync(L"my folder path").get();

StorageLibraryChangeTracker tracker = folder.TryGetChangeTracker();
if (tracker != nullptr)
{
StorageLibraryChangeTrackerOptions ops;
ops.TrackChangeDetails(false);
tracker.Enable(ops);

StorageLibraryChangeReader reader = tracker.GetChangeReader();
if (reader != nullptr)
{
    UINT32 changeId = reader.GetLastChangeId();
    if ((changeId == StorageLibraryLastChangeId::Unknown())
    {
        ScanFolderSlow();
    }
    else if (changeId == 0)
    {
        // no changes in the storage folder yet, OR nothing has changed
        ProcessNormalApplicationStartup();
    }
    else if (changeId != appsLastPersistedChangeId)
    {
        // There have been new changes since we’ve last ran, process them
        appsLastPersistedChangeId = changeId;
        ScanFolderForChanges();
    }
    else
    {
        // changeId and our last persisted change id match, also normal application startup
        ProcessNormalApplicationStartup();
    }
}
}

Remarks

By default, enabling a change tracker on a specific library or folder will track all change details as well as keep track of the last change id. By setting StorageLibraryChangeTrackerOptions::TrackChangeDetails to false and using EnableWithOptions like the example below, the system will only keep track of the last change id which uses less system storage.

If your application doesn't need details about the changes, this is the recommended approach.

Constructors

StorageLibraryChangeTrackerOptions()

Constructor for the StorageLibraryChangeTrackerOptions to be used to setup the behavior of the change tracker for a StorageFolder or StorageLibrary.

Properties

TrackChangeDetails

Used to determine if the system will track each individual change or just the last change id for a given change tracker.

Applies to

See also