private void OnUpdaterStateChanged(object sender, IAppUpdateState e) { lock (_callbackLock) { foreach (var callback in _callbacks.ToList()) { try { callback.OnStateChanged(new UpdateStateContract( Map(e.ReleaseHistory), e.Available, e.Ready, Map(e.Status), e.FilePath, e.FileArguments)); } catch (Exception ex) when(ex.IsServiceCommunicationException()) { _logger.Warn($"Callback failed: {ex.Message}"); _callbacks.Remove(callback); } catch (TimeoutException) { _logger.Warn("Callback timed out"); } } } }
private void AppUpdate_StateChanged(object sender, IAppUpdateState state) { if (ProgressStarted(state)) { HandleProgressStart(); } else if (ProgressEnded(state)) { HandleProgressEnd(); } _prevState = state; _notifyQueue.Enqueue(() => OnStateChanged(state)); }
private void AppUpdate_StateChanged(object sender, IAppUpdateState state) { _syncContext.Post(_ => StateChanged?.Invoke(sender, state), null); }
private bool ProgressEnded(IAppUpdateState state) { return(_prevState?.Status.InProgress() == true && !state.Status.InProgress()); }
private bool ProgressStarted(IAppUpdateState state) { return(_prevState?.Status.InProgress() != true && state.Status.InProgress()); }
private void OnStateChanged(IAppUpdateState state) { StateChanged?.Invoke(this, state); }