共用方式為


AppointmentStore.GetChangeTracker(String) 方法

定義

取得 AppointmentStoreChangeTracker ,提供監視 AppointmentStoreAppointment物件變更的功能。

public:
 virtual AppointmentStoreChangeTracker ^ GetChangeTracker(Platform::String ^ identity) = GetChangeTracker;
AppointmentStoreChangeTracker GetChangeTracker(winrt::hstring const& identity);
public AppointmentStoreChangeTracker GetChangeTracker(string identity);
function getChangeTracker(identity)
Public Function GetChangeTracker (identity As String) As AppointmentStoreChangeTracker

參數

identity
String

Platform::String

winrt::hstring

字串,識別存放區中的 AppointmentStoreChangeTracker 實例。

傳回

AppointmentStoreChangeTracker,提供監視AppointmentStoreAppointment物件變更的功能。

Windows 需求

裝置系列
Windows 10 Fall Creators Update (已於 10.0.16299.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v5.0 引進)
應用程式功能
appointmentsSystem

範例

此範例會使用具名變更追蹤器,以約會資訊更新應用程式的儀表板。

private async Task UpdateDashboard(AppointmentStore store)
{
    AppointmentStoreChangeTracker tracker = store.GetChangeTracker("DashboardUpdater");

    // Check to see if we were already tracking. If not then we don't know
    // what changed and we should update everything.
    if (!tracker.IsTracking)
    {
        tracker.Enable();
        UpdateFullDashboard();

        // Don't return yet. We still want to process any changes which
        // happened while we were updating the dashboard.
    }

    // check for changes
    IReadOnlyList<AppointmentStoreChange> changes;
    do
    {
        changes = await tracker.GetChangeReader().ReadBatchAsync();
        foreach (AppointmentStoreChange change in changes)
        {
            UpdateDashboardWidget(change);
        }
    } while (changes.Count > 0);
}

備註

您可以使用此方法建立多個 AppointmentStoreChangeTracker 實例。 如果您傳入字串來識別已存在於存放區中的 AppointmentStoreChangeTracker ,這個方法會傳回該實例。 如果您傳入這個方法的字串無法識別現有的 AppointmentStoreChangeTracker,這個方法會傳回新的 AppointmentStoreChangeTracker

您可以使用AppointmentStoreChangeTrackerIsTracking屬性來判斷是否已啟用 AppointmentStoreChangeTracker的變更追蹤。

適用於