Example #1
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            //开启监听线程
            startreceive    = new DataReceive(lvwUsers, lblUserCount);
            udplistenthread = new Thread(new ThreadStart(startreceive.StartListenUdp));
            udplistenthread.IsBackground = true;
            udplistenthread.Start();

            MsgBoardCast boardcast = new MsgBoardCast();

            boardcast.BoardCast(wawCMD.WAW_BC_SIGNIN);
            boardcast.BoardCastClose();

            int i = 0;

            foreach (IPAddress addr in Dns.GetHostEntry(Dns.GetHostName()).AddressList)
            {
                if (addr.AddressFamily == AddressFamily.InterNetwork)
                {
                    cmbIpList.Items.Add(addr.ToString());
                    if (addr.ToString() == InfoSet.IpPort.Address.ToString())
                    {
                        cmbIpList.SelectedIndex = i;
                    }
                    i++;
                }
            }
        }
Example #2
0
 private void cmbIpList_SelectedIndexChanged(object sender, EventArgs e)
 {
     InfoSet.IpPort.Address = IPAddress.Parse(cmbIpList.SelectedItem.ToString());
     startreceive.StopListenUdp();
     //关闭当前监听线程,创建新线程重新在新地址和端口上监听
     if (udplistenthread != null)
     {
         udplistenthread.Abort();
     }
     startreceive    = new DataReceive(lvwUsers, lblUserCount);
     udplistenthread = new Thread(new ThreadStart(startreceive.StartListenUdp));
     udplistenthread.IsBackground = true;
     udplistenthread.Start();
 }