public MainWindow() { InitializeComponent(); udpProtocol = new UDPProtocol(localPort); udpProtocol.UdpSocketReceiveStart(RunCommand); ID = Properties.Settings.Default.ID; while (ID == 0) { udpProtocol.UdpSocketSend(udpProtocol.serverIP, udpProtocol.serverPort, new byte[] { 1 }); Thread.Sleep(5000); } sendIPPortThread = new Thread(() => { while (true) { if (ID == 0) { continue; } udpProtocol.UdpSocketSend(udpProtocol.serverIP, udpProtocol.serverPort, new byte[] { 3, (byte)ID }); Thread.Sleep(10000); } }); viewScreenManager = new ViewScreenManager(ID, controlIP, controlPort, udpProtocol); chatWindowManager = new ChatWindowManager(ID, controlIP, controlPort, udpProtocol); sendIPPortThread.IsBackground = true; sendIPPortThread.Start(); }