private void button2_Click(object sender, RoutedEventArgs e) { if (true == button1.IsEnabled) { addListBoxString(listBox1, "TCP client Up"); button1.IsEnabled = false; button2.IsEnabled = false; button3.IsEnabled = true; TcpClient = new TcpClientThread(); newTcpClient = new Thread(new ThreadStart(TcpClient.TcpClientMethod)); newTcpClient.Start(); iRunType = 2; ///0 for not run, 1 for server run, 2 for client run } }