void Global_CheckForUpdatesFromServer(object sender, EventArgs e) { if (!Global.gameSettings.General.CheckForUpdates) { return; } // Check update from Server if (UpdateCheckThread != null) { if (UpdateCheckThread.ThreadState == System.Threading.ThreadState.Unstarted || UpdateCheckThread.ThreadState == System.Threading.ThreadState.Running) { return; } else { UpdateCheckThread.Join(); UpdateCheckThread = null; } } FreeNetworkThreads(); Thread connectionTestThread = new Thread(() => UpdateChecker.test_connection()); connectionTestThread.Name = "Testing network connection"; connectionTestThread.Start(); MetricsThreads.Add(connectionTestThread); UpdateCheckThread = new Thread(() => CheckForUpdate()); UpdateCheckThread.Name = "Checking for updates"; UpdateCheckThread.Start(); }
private void EndThreads() { if (GraphicsLoadingThread != null) { GraphicsLoadingThread.Abort(); GraphicsLoadingThread.Join(); } if (UpdateCheckThread != null) { UpdateCheckThread.Abort(); UpdateCheckThread.Join(); } foreach (var thread in MetricsThreads) { thread.Abort(); thread.Join(); } }