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 启用更改跟踪。

适用于