private void btnok_Click(object sender, EventArgs e) { var sys = VirtualEnvironments.Get(txtcsys.Text); if (sys != null) { //user auth var user = sys.Users.FirstOrDefault(x => x.Username == txtcuser.Text && x.Password == txtcpass.Text); if (user != null) { OpenConnection = sys; CurrentRemoteUser = user; if (Mounts.Count == 3) { Mounts.RemoveAt(2); } Mounts.Add(sys.Filesystem); ChangeDirectory("2:"); pnlconnect.Hide(); connectToRemoteServerToolStripMenuItem.Text = "Reauthenticate"; disconnectToolStripMenuItem.Visible = true; return; } Infobox.Show("Access denied.", "Authentication failed for the specified user. Connection aborted."); return; } var t = new System.Threading.Thread(() => { System.Threading.Thread.Sleep(5000); Infobox.Show("Connection timeout.", "Cannot connect to the specified system name..."); }); t.IsBackground = true; t.Start(); }