StorageLibraryLastChangeId Klasse

Definition

Ermöglicht ihnen das Nachverfolgen von Änderungen basierend auf einem eindeutigen Wert, der die letzte Änderung darstellt, die vom Indizierungsdienst für den angegebenen StorageFolder oder StorageLibrary verarbeitet wurde.

public ref class StorageLibraryLastChangeId sealed
/// [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 StorageLibraryLastChangeId final
[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 StorageLibraryLastChangeId
Public NotInheritable Class StorageLibraryLastChangeId
Vererbung
Object Platform::Object IInspectable StorageLibraryLastChangeId
Attribute

Windows-Anforderungen

Gerätefamilie
Windows 10, version 2104 (eingeführt in 10.0.20348.0)
API contract
Windows.Foundation.UniversalApiContract (eingeführt in v12.0)

Beispiele

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

Eigenschaften

Unknown

Wird zurückgegeben, wenn das USN-Journal überläuft und der Dienst mit Änderungen nicht Schritt halten kann oder es einen anderen Grund gibt, warum die Änderungs-ID nicht berechnet werden kann.

Gilt für:

Weitere Informationen