StorageLibraryChangeTrackerOptions.TrackChangeDetails 属性

定义

用于确定系统是跟踪每个单独的更改,还是只跟踪给定更改跟踪器的最后一个更改 ID。

public:
 property bool TrackChangeDetails { bool get(); void set(bool value); };
bool TrackChangeDetails();

void TrackChangeDetails(bool value);
public bool TrackChangeDetails { get; set; }
var boolean = storageLibraryChangeTrackerOptions.trackChangeDetails;
storageLibraryChangeTrackerOptions.trackChangeDetails = boolean;
Public Property TrackChangeDetails As Boolean

属性值

Boolean

bool

一个布尔值,确定更改跟踪器是应跟踪所有更改详细信息还是仅跟踪最后一个更改 ID。如果未设置或修改,则默认为 true。

示例

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

注解

对于所有更改跟踪器,TrackChangeDetails 默认为 true。 在传递到 StorageLibraryChangeTracker::EnableWithOptions 时,可以将其设置为 false,以便在应用程序只关注最后一个更改 ID 而不是每个单独更改的详细信息时保存在系统存储上。

适用于

另请参阅