예제 #1
0
        private void ThreadUpdateApp(CancellationToken cancellationToken)
        {
            _state.Value = PatcherState.UpdatingApp;

            _remoteVersionId.Value = _app.GetLatestVersionId();
            if (_app.IsInstalled())
            {
                _localVersionId.Value = _app.GetInstalledVersionId();
            }

            _updateAppCancellationTokenSource = new CancellationTokenSource();

            using (cancellationToken.Register(() => _updateAppCancellationTokenSource.Cancel()))
            {
                var appUpdater = new AppUpdater.AppUpdater(new AppUpdaterContext(_app, _configuration.AppUpdaterConfiguration));
                appUpdater.Context.StatusMonitor.OverallStatusChanged += OnUpdateAppStatusChanged;

                try
                {
                    appUpdater.Update(_updateAppCancellationTokenSource.Token);
                }
                finally
                {
                    appUpdater.Context.StatusMonitor.OverallStatusChanged -= OnUpdateAppStatusChanged;
                    _updateAppCancellationTokenSource = null;
                }
            }
        }
예제 #2
0
        private void ThreadUpdateApp(bool automatically, CancellationToken cancellationToken)
        {
            _state.Value = PatcherState.Connecting;

            _updateAppCancellationTokenSource = new PatchKit.Unity.Patcher.Cancellation.CancellationTokenSource();

            using (cancellationToken.Register(() => _updateAppCancellationTokenSource.Cancel()))
            {
                _appInfo.Value         = _app.RemoteMetaData.GetAppInfo(!automatically, _updateAppCancellationTokenSource.Token);
                _remoteVersionId.Value = _app.GetLatestVersionId(!automatically, _updateAppCancellationTokenSource.Token);
                if (_app.IsFullyInstalled())
                {
                    _localVersionId.Value = _app.GetInstalledVersionId();
                }

                var appUpdater = new AppUpdater.AppUpdater(new AppUpdaterContext(_app, _configuration.AppUpdaterConfiguration));

                try
                {
                    _updaterStatus.Value = appUpdater.Status;

                    using (_updaterStatus.Take(1).Subscribe((status) => _state.Value = PatcherState.UpdatingApp))
                    {
                        appUpdater.Update(_updateAppCancellationTokenSource.Token);
                        _wasUpdateSuccessfulOrNotNecessary = true;
                    }
                }
                catch (OperationCanceledException)
                {
                    PatcherStatistics.DispatchSendEvent(PatcherStatistics.Event.PatcherCanceled);

                    throw;
                }
                finally
                {
                    _state.Value = PatcherState.None;

                    _updaterStatus.Value = null;
                    _updateAppCancellationTokenSource = null;
                }
            }
        }
예제 #3
0
        private void ThreadUpdateApp(CancellationToken cancellationToken)
        {
            _state.Value = PatcherState.UpdatingApp;

            _updateAppCancellationTokenSource = new CancellationTokenSource();

            using (cancellationToken.Register(() => _updateAppCancellationTokenSource.Cancel()))
            {
                var appUpdater = new AppUpdater.AppUpdater(_app, _configuration.AppUpdaterConfiguration);

                appUpdater.Context.StatusMonitor.OverallStatusChanged += OnUpdateAppStatusChanged;

                try
                {
                    appUpdater.Update(_updateAppCancellationTokenSource.Token);
                }
                finally
                {
                    appUpdater.Context.StatusMonitor.OverallStatusChanged -= OnUpdateAppStatusChanged;
                    _updateAppCancellationTokenSource = null;
                }
            }
        }