Exemple #1
0
 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");
             }
         }
     }
 }
Exemple #2
0
        private void AppUpdate_StateChanged(object sender, IAppUpdateState state)
        {
            if (ProgressStarted(state))
            {
                HandleProgressStart();
            }
            else if (ProgressEnded(state))
            {
                HandleProgressEnd();
            }

            _prevState = state;
            _notifyQueue.Enqueue(() => OnStateChanged(state));
        }
Exemple #3
0
 private void AppUpdate_StateChanged(object sender, IAppUpdateState state)
 {
     _syncContext.Post(_ => StateChanged?.Invoke(sender, state), null);
 }
Exemple #4
0
 private bool ProgressEnded(IAppUpdateState state)
 {
     return(_prevState?.Status.InProgress() == true && !state.Status.InProgress());
 }
Exemple #5
0
 private bool ProgressStarted(IAppUpdateState state)
 {
     return(_prevState?.Status.InProgress() != true && state.Status.InProgress());
 }
Exemple #6
0
 private void OnStateChanged(IAppUpdateState state)
 {
     StateChanged?.Invoke(this, state);
 }