private void btnConnect_Click(object sender, RoutedEventArgs e) { NetConnection.connect(txtOct1.Text, txtOct2.Text, txtOct3.Text, txtOct4.Text); if (communicationThread == null) { communicationThread = new Thread(new ParameterizedThreadStart(setUser)); communicationThread.Start(txtUserName.Text); } ChatClient chatWindow = new ChatClient(); chatWindow.setSocket(ref NetConnection.ConnectionStream); chatWindow.MyUsername = txtUserName.Text; chatWindow.Show(); this.Close(); }