Program Hanging after changing ip

Nov 13, 2015 at 12:19 PM
Hello all and straight to the problem.
using (var client = new SshClient(ipTXT.Text, userTXT.Text, passwordTXT.Text))
            {
                consoleTXT.Text = "Connecting..."+"\r\n";
                client.ConnectionInfo.Timeout = TimeSpan.FromSeconds(3);
                try
                {
                    client.Connect();
                    consoleTXT.Text += "Connected" + "\r\n";
                    client.RunCommand("cp /etc/network/interfaces /home/pi/interfaces");
blah blah blah change  the ip and just before the end I do this:
client.RunCommand("sudo /etc/init.d/networking restart");
client.Disconnect();
everything works, the ip changes. The problem is that my form hangs after the networking restart obv because I am changing the ip. Is there anything I can do?

Thank you