public async Task RefreshLivestreams() { refreshTimer.Stop(); try { await StreamsModel.RefreshLivestreams(); refreshErrorCount = 0; // only reactive the timer if we're still on this screen if (IsActive) { refreshTimer.Start(); } } catch (Exception ex) { if (!IsActive) { return; } refreshErrorCount++; // keep trying to refresh until we hit too many consecutive errors if (refreshErrorCount >= 3) { Execute.OnUIThread(async() => { await this.ShowMessageAsync("Error refreshing livestreams", ex.ExtractErrorMessage()); refreshTimer.Start(); }); } else { refreshTimer.Start(); } } }
public async Task RefreshLivestreams() { refreshTimer.Stop(); try { await StreamsModel.RefreshLivestreams(); refreshErrorCount = 0; // only reactive the timer if we're still on this screen if (IsActive) { refreshTimer.Start(); } } catch (AggregateException aggregateException) { if (!IsActive) { return; } refreshErrorCount++; // keep trying to refresh until we hit too many consecutive errors unless it's our first query if (refreshCount == 0 || refreshErrorCount >= 3) { foreach (var ex in aggregateException.InnerExceptions) { var messageDialogResult = await this.ShowMessageAsync( "Error refreshing livestreams", ex.ExtractErrorMessage(), MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings() { NegativeButtonText = "Ignore" }); if (messageDialogResult == MessageDialogResult.Negative) { StreamsModel.IgnoreQueryFailure(ex.Message); } } refreshTimer.Start(); } else { refreshTimer.Start(); } } catch (Exception ex) { if (!IsActive) { return; } refreshErrorCount++; await this.ShowMessageAsync("Error refreshing livestreams", ex.ExtractErrorMessage()); } refreshCount++; }