static void Main() { CsToolClass.install(); // Show the login form. LoginForm login = new LoginForm(); DialogResult res = login.ShowDialog(); if (res == DialogResult.Cancel) { // no validation, so exit. return; } // store the login info, and connect to the LS if (!CsToolClass.getInstance().installClient(login.getAddress(), 10666)) { return; // die. } CsToolClass.getInstance().sendMessage("login " + login.userName + " " + login.password); // wait for a response. string response; int timeWaited = 0; while (true) { Thread.Sleep(100); response = CsToolClass.getInstance().getMessage(); if (response != "") { break; } timeWaited += 100; if (timeWaited > 5000) { MessageBox.Show("Error - no response from server.", "Could not log in"); return; } } // see if we were successful. if (response.StartsWith("Logged in successfully")) { // fire off the main form. MainForm main = new MainForm(login.getAddress()); main.ShowDialog(); } else { MessageBox.Show("Error! Could not log in. Please check name/password and try again.", "Login error"); } }