Esempio n. 1
0
        /// <summary>
        /// 连接服务器
        /// </summary>
        private void InterChatMenuItem_Click(object sender, EventArgs e)
        {
            lbOnlineUsers.Items.Clear();
            LoginForm loginDlg = new LoginForm();
            if (loginDlg.ShowDialog() == DialogResult.OK)
            {
                userName = loginDlg.txtUserName.Text;
                loginDlg.Close();
            }

            txtChatContent.Focus();
            Application.DoEvents();
            InstanceContext site = new InstanceContext(this);//为实现服务实例的对象进行初始化
            proxy = new ChatServiceClient(site);
            IAsyncResult iar = proxy.BeginJoin(userName, new AsyncCallback(OnEndJoin), null);
            wfDlg.ShowDialog();
        }