Skip to content

Latest commit

 

History

History
62 lines (52 loc) · 1.66 KB

storagelibrarychangetracker_disable_855128550.md

File metadata and controls

62 lines (52 loc) · 1.66 KB
-api-id -api-type
M:Windows.Storage.StorageLibraryChangeTracker.Disable
winrt method

Windows.Storage.StorageLibraryChangeTracker.Disable

-description

Disables change tracking for the StorageFolder or StorageLibrary.

-remarks

This method will do nothing if the calling application has not yet called Enable on the StorageFolder/StorageLibrary.

-see-also

StorageLibraryChangeTracker.Enable

-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();
    }
}
}