Gallifrey.Versions.VersionControl.CheckForUpdates C# (CSharp) Méthode

CheckForUpdates() public méthode

public CheckForUpdates ( bool manualCheck = false ) : Task
manualCheck bool
Résultat Task
        public Task<UpdateResult> CheckForUpdates(bool manualCheck = false)
        {
            if (!IsAutomatedDeploy)
            {
                return Task.Factory.StartNew(() => UpdateResult.NotDeployable);
            }

            if (lastUpdateCheck >= DateTime.UtcNow.AddMinutes(-5) && !manualCheck)
            {
                return Task.Factory.StartNew(() => UpdateResult.TooSoon);
            }

            if (manualCheck)
            {
                trackUsage.TrackAppUsage(TrackingType.UpdateCheckManual);
            }
            else
            {
                trackUsage.TrackAppUsage(TrackingType.UpdateCheck);
            }
            lastUpdateCheck = DateTime.UtcNow;

            try
            {
                var updateInfo = ApplicationDeployment.CurrentDeployment.CheckForDetailedUpdate(false);

                if (updateInfo.UpdateAvailable && updateInfo.AvailableVersion > ApplicationDeployment.CurrentDeployment.CurrentVersion)
                {
                    return Task.Factory.StartNew(() => ApplicationDeployment.CurrentDeployment.Update()).ContinueWith(task =>
                    {
                        SetVersionName();
                        UpdateInstalled = true;
                        NewVersionInstalled?.Invoke(this, null);
                        return UpdateResult.Updated;
                    });
                }

                return Task.Factory.StartNew(() =>
                {
                    if (manualCheck)
                    {
                        Task.Delay(1500);
                    }
                    return UpdateResult.NoUpdate;
                });
            }
            catch (TrustNotGrantedException)
            {
                return Task.Factory.StartNew(() => UpdateResult.ReinstallNeeded);
            }
            catch (Exception)
            {
                return Task.Factory.StartNew(() => UpdateResult.Error);
            }
        }