public void reset(int node, string port, Connection connection) { try { Console.WriteLine("Automatic reset in progress."); _serialPort.Close(); Console.WriteLine("Disconnected from port " + port + "."); for (int i = 0; i < 100; i++) { Thread.Sleep(120); Console.Write("\rReset progress: {0}%", i + 1); } Console.Write("\rReset progress: {0}%", 100); Console.WriteLine("\nReconnecting to " + port + "."); _serialPort.Open(); readClass = new ConsoleRead(); readClass._continue = true; readThread = new Thread(() => readClass.Read(_serialPort, node, port, connection)); readThread.Start(); Console.WriteLine("Port " + port + " connected as node " + node + "."); Console.WriteLine("Connection to port " + port + " successfully reset."); } catch (Exception exception) { Console.WriteLine("Reset: " + exception.Message); disconnect(false); } }
public void reset(int node, string port, Connection connection) { try { Console.WriteLine("Automatic reset in progress."); _serialPort.Close(); Console.WriteLine("Disconnected from port " + port + "."); for (int i = 0; i < 100; i++) { Thread.Sleep(120); Console.Write("\rReset progress: {0}%", i + 1); } Console.Write("\rReset progress: {0}%", 100); Console.WriteLine("\nReconnecting to " + port + "."); _serialPort.Open(); readClass = new ConsoleRead(); readClass._continue = true; readThread = new Thread(() => readClass.Read(_serialPort, node, port, connection)); readThread.Start(); Console.WriteLine("Port " + port + " connected as node " + node + "."); Console.WriteLine("Connection to port " + port + " successfully reset."); } catch (Exception exception) { Console.WriteLine("Reset: " + exception.Message); disconnect(false); } }