private ImageDataSource() { //Setup the dispatcher for the UI thread _dispatcher = Windows.UI.Xaml.Window.Current.Dispatcher; // 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 this.itemCache = new ItemCacheManager <ImageItem>(fetchDataCallback, 50); this.itemCache.CacheChanged += ItemCache_CacheChanged; }
// Handles a change notification for the list of files from the OS private void ResetCollection() { // Unhook the old change notification if (itemCache != null) { this.itemCache.CacheChanged -= ItemCache_CacheChanged; } // Create a new instance of the cache manager this.itemCache = new ItemCacheManager <ImageItem>(fetchDataCallback, 50); this.itemCache.CacheChanged += ItemCache_CacheChanged; CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); }
//Required for the IItemsRangeInfo interface public void Dispose() { itemCache = null; }