/// <summary> /// Checks if a new version exists and if it does, it stops the master server, downloads it and restarts it again /// </summary> private static void CheckNewVersion() { Task.Run(async() => { while (true) { var latestVersion = UpdateChecker.GetLatestVersion(); if (latestVersion > CurrentVersion) { ConsoleLogger.Log(LogLevels.Normal, $"Found a new updated version! Current: {CurrentVersion} Latest: {latestVersion}"); ConsoleLogger.Log(LogLevels.Normal, "Downloading and restarting program...."); var url = UpdateDownloader.GetZipFileUrl(DebugVersion); if (!string.IsNullOrEmpty(url)) { var zipFileName = url.Substring(url.LastIndexOf("/") + 1); UpdateDownloader.DownloadZipFile(url, Path.Combine(Directory.GetCurrentDirectory(), zipFileName)); StopMasterServerDll(); UpdateExtractor.ExtractZipFileToDirectory(Path.Combine(Directory.GetCurrentDirectory(), zipFileName), Directory.GetCurrentDirectory(), UpdateExtractor.ProductToExtract.MasterServer); StartMasterServerDll(); } } //Sleep for 30 minutes... await Task.Delay(30 * 60 * 1000); } }); }