public CalendarItemList(Func <List <DateTime>, CancellationToken, Task <ICalendarItem[]> > fetchDataCallback) { // Setup the dispatcher for the UI thread _dispatcher = Microsoft.UI.Xaml.Window.Current.Dispatcher; _fetchDataCallback = (range, c) => fetchDataCallback(ConvertIndexRangeToDateTimeRange(range), c); _pivotDay = DateTimeOffset.Now.Date; // The ItemCacheManager does most of the heavy lifting. We pass it a callback that it will use to actually fetch data, and the max size of a request itemCache = new ItemCacheManager <ICalendarItem>(_fetchDataCallback, 50); itemCache.CacheChanged += ItemCache_CacheChanged; }
private void ResetCollection() { // Unhook the old change notification if (itemCache != null) { itemCache.CacheChanged -= ItemCache_CacheChanged; } // Create a new instance of the cache manager itemCache = new ItemCacheManager <ICalendarItem>(_fetchDataCallback, 50); itemCache.CacheChanged += ItemCache_CacheChanged; if (CollectionChanged != null) { CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset, null, null, 0, 0)); } }