From 50b76223b838fc7e802861850a085a2e397600c5 Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Thu, 15 Aug 2019 17:09:07 -0400 Subject: [PATCH] Fix updater --- Toolbox/MainForm.cs | 5 +++++ Toolbox/UpdateProgram.cs | 35 ++++++++++++++++------------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/Toolbox/MainForm.cs b/Toolbox/MainForm.cs index 520b3e5d..ba613093 100644 --- a/Toolbox/MainForm.cs +++ b/Toolbox/MainForm.cs @@ -92,6 +92,11 @@ namespace Toolbox version.SaveVersionInfo(); } + ThreadStart t = new ThreadStart(UpdateProgram.CheckLatest); + Thread thread = new Thread(t); + thread.Start(); + + Application.Idle += Application_Idle; if (Runtime.UseOpenGL) { diff --git a/Toolbox/UpdateProgram.cs b/Toolbox/UpdateProgram.cs index 905cae60..e449b413 100644 --- a/Toolbox/UpdateProgram.cs +++ b/Toolbox/UpdateProgram.cs @@ -12,7 +12,7 @@ namespace Toolbox { public class UpdateProgram { - static List Releases; + static Release[] releases; public static bool CanUpdate = false; public static bool Downloaded = false; public static Release LatestRelease; @@ -28,7 +28,7 @@ namespace Toolbox GetReleases(client).Wait(); GetCommits(client).Wait(); - foreach (Release latest in Releases) + foreach (Release latest in releases) { Console.WriteLine( "The latest release is tagged at {0} and is named {1} commit {2} date {3}", @@ -43,23 +43,19 @@ namespace Toolbox LatestRelease = latest; CanUpdate = true; - /* DownloadRelease(); - if (CanUpdate) - { - LatestReleaseTime = latest.Assets[0].UpdatedAt.DateTime; - LatestRelease = latest; - } - else - { - - }*/ + /* DownloadRelease(); + if (CanUpdate) + { + LatestReleaseTime = latest.Assets[0].UpdatedAt.DateTime; + LatestRelease = latest; + } + else + { + + }*/ } break; } - - Releases.Clear(); - CommitList.Clear(); - client = null; } catch (Exception ex) { @@ -102,7 +98,7 @@ namespace Toolbox DateTimeOffset CurrentRelease; bool IsValidTime = DateTimeOffset.TryParse(Runtime.CompileDate, out CurrentRelease); - foreach (GitHubCommit c in await client.Repository.Commit.GetAll("KillzXGaming", "Switch-Toolbox", options)) + foreach (GitHubCommit c in await client.Repository.Commit.GetAll("KillzXGaming", "Switch-Toolbox", options)) { if (IsValidTime) { @@ -121,9 +117,10 @@ namespace Toolbox static async Task GetReleases(GitHubClient client) { - Releases.Clear(); + List Releases = new List(); foreach (Release r in await client.Repository.Release.GetAll("KillzXGaming", "Switch-Toolbox")) Releases.Add(r); + releases = Releases.ToArray(); } } -} +} \ No newline at end of file