private void BtnJoinOnClick(object sender, RoutedEventArgs e) { PanelOfClient.Visibility = Visibility.Collapsed; ProgressRing.Visibility = Visibility.Visible; if (!ValidationAdress(TbAdress.Text)) { PrintAndReturnButton("Ошибка", "Неверный IP адрес"); return; } byte[] ipAdress = getIpAdress(TbAdress.Text); int port = int.Parse(NumPort.Value.ToString()); string login = TbLogin.Text; ClientCore client; new Thread(() => { client = ClientCore.InicializeClient(ipAdress, port); if (client == null) { ClientCore.RemoveClient(); MessageOnError(null, "Что-то пошло не так, попробуйте снова"); return; } client.Error -= MessageOnError; client.Error += MessageOnError; client.Join -= OpenPageServer; client.Join += OpenPageServer; client.JoinServer(login); }).Start(); }