public void UpdateProgress(IProgress prog) { long total = 0; long value = 0; lock (tasks) { if (!tasks.ContainsKey(prog.Task)) { tasks.Add(prog.Task, prog); } else { tasks[prog.Task] = prog; } total = tasks.Values.Select(x => x.Total).Sum(); value = tasks.Values.Select(x => x.Value).Sum(); if (prog.Percentage == 1f) { tasks.Remove(prog.Task); } } progress.UpdateProgress(value, total, prog.Message); OnProgress?.Invoke(progress); }
public void Run() { isBusy = true; progress.UpdateProgress(0, 100, "Initializing..."); if (firstRun) { UsageTracker.IncrementNumberOfStartups(); } var thread = new Thread(() => { GitInstallationState state = new GitInstallationState(); try { if (Environment.IsMac) { var getEnvPath = new SimpleProcessTask(TaskManager.Token, "bash".ToNPath(), "-c \"/usr/libexec/path_helper\"") .Configure(ProcessManager, dontSetupGit: true) .Catch(e => true); // make sure this doesn't throw if the task fails var path = getEnvPath.RunSynchronously(); if (getEnvPath.Successful) { Logger.Trace("Existing Environment Path Original:{0} Updated:{1}", Environment.Path, path); Environment.Path = path?.Split(new[] { "\"" }, StringSplitOptions.None)[1]; } } progress.UpdateProgress(20, 100, "Setting up octorun..."); Environment.OctorunScriptPath = new OctorunInstaller(Environment, TaskManager) .SetupOctorunIfNeeded(); progress.UpdateProgress(50, 100, "Setting up git..."); state = Environment.GitInstallationState; if (!state.GitIsValid && !state.GitLfsIsValid && FirstRun) { // importing old settings NPath gitExecutablePath = Environment.SystemSettings.Get(Constants.GitInstallPathKey, NPath.Default); if (gitExecutablePath.IsInitialized) { Environment.SystemSettings.Unset(Constants.GitInstallPathKey); state.GitExecutablePath = gitExecutablePath; state.GitInstallationPath = gitExecutablePath.Parent.Parent; Environment.GitInstallationState = state; } } var installer = new GitInstaller(Environment, ProcessManager, TaskManager.Token); installer.Progress.OnProgress += progressReporter.UpdateProgress; if (state.GitIsValid && state.GitLfsIsValid) { if (firstRun) { installer.ValidateGitVersion(state); if (state.GitIsValid) { installer.ValidateGitLfsVersion(state); } } } if (!state.GitIsValid || !state.GitLfsIsValid) { state = installer.SetupGitIfNeeded(); } SetupGit(state); progress.UpdateProgress(80, 100, "Initializing repository..."); if (state.GitIsValid && state.GitLfsIsValid) { RestartRepository(); } progress.UpdateProgress(100, 100, "Initialization failed"); } catch (Exception ex) { Logger.Error(ex, "A problem ocurred setting up Git"); progress.UpdateProgress(90, 100, "Initialization failed"); } new ActionTask <bool>(TaskManager.Token, (s, gitIsValid) => { InitializationComplete(); if (gitIsValid) { InitializeUI(); } }, () => state.GitIsValid && state.GitLfsIsValid) { Affinity = TaskAffinity.UI } .Start(); }); thread.Start(); }
public void UpdateProgress(long value, long total, string message = null) { progress.UpdateProgress(value, total, message ?? this.Message); }
protected void UpdateProgress(long value, long total) { progress.UpdateProgress(value, total); progressHandler?.Invoke(progress); }