public static void StartThreads() { if (_shipThread != null) { _shipThread.Abort(); int num = 0; while (true) { if (!_shipThread.IsAlive) { if (_shipThread.ThreadState != System.Threading.ThreadState.Running) { break; } } if (num >= 5) { break; } num++; Thread.Sleep(1000); } } if (_connectionThread != null) { _connectionThread.Abort(); int num = 0; while (true) { if (!_connectionThread.IsAlive) { if (_connectionThread.ThreadState != System.Threading.ThreadState.Running) { break; } } if (num >= 5) { break; } num++; Thread.Sleep(1000); } } if ((Bot._botThread == null || !Bot.Running) && BotLogic.attacking >= 0) { BotLogic.StartBotThread(); } _shipThread = new Thread((ShipThread)); _shipThread.Start(); _connectionThread = new Thread((ConnectionThread)); _connectionThread.Start(); }