public override async void Load(object userState) { _currentUserState = userState; if (IsBusy) { return; } if (AsyncRemoteCollectionView.PageIndex < 0) { return; } IsBusy = true; LoadStarted?.Invoke(this, EventArgs.Empty); try { var result = await _load(); CurrentResult = result; _onLoadCompleted?.Invoke(result); OnLoadCompleted(new AsyncCompletedEventArgs(result.Error, result.IsCanceled, _currentUserState)); } catch (Exception ex) { OnLoadCompleted(new AsyncCompletedEventArgs(ex, false, null)); } finally { IsBusy = false; } }
public void Handle(string file, ILoadResult result) { switch (result) { case LoadBusy: Log($"[{file}]\nLoading..."); hoveredFile = null; break; case LoadFailure f: Log($"[{file}]\n{f.message}"); hoveredFile = null; break; case LoadSuccess s: Log($"[{file}]\nLoaded successfully"); hoveredFile = s.preview; break; case LoadNonexistent s: Log($"[{file}]\nDoes not exist"); hoveredFile = null; break; } }
protected override void OnLoadCompleted(object sender, AsyncCompletedEventArgs e) { IsRefreshing = false; Refreshed?.Invoke(this, EventArgs.Empty); var loader = CollectionViewLoader as AsyncRemoteCollectionViewLoader; ILoadResult operation = loader.CurrentResult; if (operation.Error != null || operation.IsCanceled) { return; } IEnumerable <object> result = operation.Result.Cast <object>(); var source = CollectionView.SourceCollection as List <object>; source.Clear(); foreach (var item in result) { source.Add(item); } SetTotalItemCount(operation.TotalCount); base.OnLoadCompleted(sender, e); }
/// <summary> /// Update the observable result collections. /// </summary> /// <param name="result">The results of the completed load operation.</param> private protected virtual void UpdateResults(ILoadResult result) { if (result == null) { throw new ArgumentNullException(nameof(result)); } // if the Entities property has been examined, update the backing // observable collection this._entities?.Reset(result.Entities); // if the AllEntities property has been examined, update the backing // observable collection this._allEntities?.Reset(result.AllEntities); }
private void OnAsyncLoadCompleted(ILoadResult loadResult) { //MessageBox.Show("LoadCompleted"); }
private void OnAsyncLoadCompleted(ILoadResult loadResult) { }