From 576326f8efc305c80ab45a44aad43d1f2a66e2b7 Mon Sep 17 00:00:00 2001 From: Alex-TIMEHACK Date: Wed, 28 Jun 2017 17:59:04 +0100 Subject: Increased startup performance --- TimeHACK.Main/Program.cs | 59 +++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 23 deletions(-) (limited to 'TimeHACK.Main/Program.cs') diff --git a/TimeHACK.Main/Program.cs b/TimeHACK.Main/Program.cs index 673ab07..72a7291 100644 --- a/TimeHACK.Main/Program.cs +++ b/TimeHACK.Main/Program.cs @@ -21,7 +21,7 @@ namespace TimeHACK internal static bool nightly = true; internal static string gameID; - internal static TitleScreen title = null; + internal static TitleScreen title; public static string AddressBookSelectedFolderName; public static AddressBookContact AddressBookSelectedContact; public static string WindowsExplorerReturnPath; @@ -34,26 +34,15 @@ namespace TimeHACK [STAThread] static void Main(string[] args) { - if (nightly == true) - { - try - { - WebClient wc = new WebClient(); + Application.SetCompatibleTextRenderingDefault(false); - // Set the GameID - string json = wc.DownloadString("http://ci.appveyor.com/api/projects/timehack/timehack"); - JObject j = JObject.Parse(JObject.Parse(json)["build"].ToString()); - gameID = "AppVeyor-" + j["buildNumber"].ToString(); - } - catch (WebException) - { - gameID = "AppVeyor"; - } - } - else - { - gameID = "TimeHACK 1.1"; - } + title = new TitleScreen(); + + gameID = "Getting AppVeyor..."; + System.Threading.Thread getAppVeyor = new System.Threading.Thread(GetAppVeyor); + + getAppVeyor.Start(); + System.Threading.Thread.Sleep(500); //TimeHACK.Engine.GameSave.SaveData MySaveData = new TimeHACK.Engine.GameSave.SaveData() //{ @@ -72,9 +61,8 @@ namespace TimeHACK //MySaveData = (TimeHACK.Engine.GameSave.SaveData)JsonConvert.DeserializeObject(TheJSON, MySaveData.GetType()); //MessageBox.Show(MySaveData.OS.ToString()); - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(title = new TitleScreen()); + Application.EnableVisualStyles(); + Application.Run(title); } public static String OpenFileExplorerAsDialogAndReturnGivenPath() @@ -100,5 +88,30 @@ namespace TimeHACK System.Threading.Thread.Sleep(1500); Application.Exit(); } + + public static void GetAppVeyor() + { + if (nightly == true) + { + try + { + WebClient wc = new WebClient(); + + // Set the GameID + string json = wc.DownloadString("http://ci.appveyor.com/api/projects/timehack/timehack"); + JObject j = JObject.Parse(JObject.Parse(json)["build"].ToString()); + gameID = "AppVeyor-" + j["buildNumber"].ToString(); + } + catch (WebException) + { + gameID = "AppVeyor"; + } + } + else + { + gameID = "TimeHACK 1.1"; + } + + } } } -- cgit v1.2.3