diff --git a/CreamInstaller/CreamInstaller.csproj b/CreamInstaller/CreamInstaller.csproj index 9d5cd35..066bf5a 100644 --- a/CreamInstaller/CreamInstaller.csproj +++ b/CreamInstaller/CreamInstaller.csproj @@ -5,7 +5,7 @@ True Resources\ini.ico true - 2.3.1.0 + 2.3.1.1 Resources\ini.ico Automatically generates and installs CreamAPI files for Steam games on the user's computer. It can also generate and install CreamAPI for the Paradox Launcher should the user select a Paradox Interactive game. diff --git a/CreamInstaller/Forms/SelectForm.cs b/CreamInstaller/Forms/SelectForm.cs index 5ef280e..0ad5905 100644 --- a/CreamInstaller/Forms/SelectForm.cs +++ b/CreamInstaller/Forms/SelectForm.cs @@ -192,9 +192,10 @@ internal partial class SelectForm : CustomForm } int CompleteTasks = 0; - RunningTasks.Clear(); - RemainingGames.Clear(); - RemainingDLCs.Clear(); + RunningTasks.Clear(); // contains all running tasks including games AND their dlc + RemainingGames.Clear(); // for display purposes only, otherwise ignorable + RemainingDLCs.Clear(); // for display purposes only, otherwise ignorable + List appTasks = new(); foreach (Tuple program in applicablePrograms) { int appId = program.Item1; @@ -205,10 +206,10 @@ internal partial class SelectForm : CustomForm ProgramSelection selection = ProgramSelection.FromAppId(appId); if (Program.Canceled) return; if (Program.IsGameBlocked(name, directory)) continue; - RunningTasks.Add(Task.Run(async () => + AddToRemainingGames(name); + Task task = Task.Run(async () => { if (Program.Canceled) return; - AddToRemainingGames(name); List dllDirectories = await GetDllDirectoriesFromGameDirectory(directory); if (dllDirectories is null) { @@ -231,10 +232,10 @@ internal partial class SelectForm : CustomForm foreach (int id in dlcIds) { if (Program.Canceled) return; + AddToRemainingDLCs(id.ToString()); Task task = Task.Run(async () => { if (Program.Canceled) return; - AddToRemainingDLCs(id.ToString()); string dlcName = null; VProperty dlcAppInfo = await SteamCMD.GetAppInfo(id); if (dlcAppInfo is not null) dlcName = dlcAppInfo.Value?.GetChild("common")?.GetChild("name")?.ToString(); @@ -265,6 +266,11 @@ internal partial class SelectForm : CustomForm RemoveFromRemainingGames(name); return; } + foreach (Task task in dlcTasks) + { + if (Program.Canceled) return; + await task; + } selection ??= new(); selection.Usable = true; @@ -284,11 +290,6 @@ internal partial class SelectForm : CustomForm } if (allCheckBox.Checked) selection.Enabled = true; - foreach (Task task in dlcTasks) - { - if (Program.Canceled) return; - await task; - } if (Program.Canceled) return; Program.Invoke(selectionTreeView, delegate { @@ -322,10 +323,12 @@ internal partial class SelectForm : CustomForm if (Program.Canceled) return; RemoveFromRemainingGames(name); progress.Report(++CompleteTasks); - })); + }); + appTasks.Add(task); + RunningTasks.Add(task); progress.Report(-RunningTasks.Count); } - foreach (Task task in RunningTasks.ToList()) + foreach (Task task in appTasks) { if (Program.Canceled) return; await task;