private void ProcessError(PendingGetResult pendingResult, Exception ex) { try { m_data.Keys.SetLoadingStateForKeys(pendingResult.KeysRequested, false); Error.SafeInvokeInUIThread(this, ex); } catch { } }
private void ProcessNotFoundItems(PendingGetResult pendingResult) { if (pendingResult.KeysNotFound.IsNullOrEmpty() || !m_data.HasKeys) { return; } m_data.Keys.SetLoadingStateForKeys(pendingResult.KeysNotFound, false); ItemsNotFound.SafeInvokeInUIThread(this, pendingResult.KeysNotFound); }
private void ProcessFoundItems(PendingGetResult pendingResult, bool fireEvent) { if (pendingResult.KeysFound.IsNullOrEmpty() || !m_data.HasKeys) { return; } m_data.Keys.SetLoadingStateForKeys(pendingResult.KeysFound, false); if (fireEvent) { ItemsAvailable.SafeInvokeInUIThread(this, pendingResult.KeysFound); } }
private void PendingGetCompletion(object sender, PendingGetResult result) { try { result.EnsureSuccess(); ProcessFoundItems(result, true); ProcessNotFoundItems(result); } catch (Exception ex) { ProcessError(result, ex); } }
private void NotifyPendingGetComplete(PendingGetCompletionDelegate callback, PendingGetResult result) { if (callback != null) { try { callback(this, result); } catch { } } }
internal async Task<PendingGetResult> DownloadItems(IList<ItemKey> keys, IList<string> typeVersions, PendingGetCompletionDelegate callback, CancellationToken cancelToken) { var result = new PendingGetResult(); try { result.KeysRequested = keys; ItemQuery query = this.CreateRefreshQueryForKeys(keys, typeVersions); IList<RecordItem> items = await m_remoteStore.GetAllItemsAsync(query); await this.PersistDownloadedItemsAsync(items); result.KeysFound = ( from item in items select item.Key ).ToArray(); } catch (Exception ex) { result.Exception = ex; } NotifyPendingGetComplete(callback, result); return result; }