Exemplo n.º 1
0
 /// <summary>
 /// 释放使用资源
 /// </summary>
 private void AbortProxyAndUpdateUI()
 {
     if (proxy != null)
     {
         proxy.Abort();
         proxy.Close();
         proxy = null;
     }
     ShowInterChatMenuItem(true);
 }
Exemplo n.º 2
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 ServiceReference1.MyMessageClient(site);

            IAsyncResult iar = proxy.BeginJoin(userName, new AsyncCallback(OnEndJoin), null);

            wfDlg.ShowDialog();
        }