Esempio n. 1
0
        public chatWindow(string in_his_ip, string in_my_ip, string in_his_name, string in_my_name, Net_class sock)
        {
            InitializeComponent();
            FormClosing += new FormClosingEventHandler(chatWindow_FormClosing); //注册窗口关闭事件

            listView_message.Columns[0].Width     = 100;
            listView_message.Columns[0].TextAlign = HorizontalAlignment.Center;
            listView_message.Columns[1].Width     = listView_message.Width - listView_message.Columns[0].Width;

            his_port = sock.get_his_port();
            my_port  = sock.get_my_port();
            his_ip   = in_his_ip;
            my_ip    = in_my_ip;
            his_name = in_his_name;
            my_name  = in_my_name;

            this.Text = "聊天:" + his_name;

            sock.Close();

            receive_sock = new UdpClient(my_port);
            send_sock    = new UdpClient();

            CheckForIllegalCrossThreadCalls = false;
            receive_tr = new Thread(new ThreadStart(clientChat_receive));
            receive_tr.IsBackground = true;
            receive_tr.Start();
        }