private void button1_Click(object sender, RoutedEventArgs e) { Clients client = new Clients(); try { string message = login.templogin + ":" + " " + textBox1.Text; string sendmsg = "*"+listBox1.SelectedItem.ToString()+"*"; client.SendMessage(sendmsg + message); //sending message trough UDP} textBox1.Text = ""; } catch { } }
public MainWindow() { InitializeComponent(); Clients client = new Clients(); Thread sendusername=new Thread(()=>client.SendName(login.templogin)); // send login trough UDP sendusername.Start(); Server server = new Server(); server.GetMessage(); server.MsgChanged += this.DoSomething; }