private void connectToolStripMenuItem_Click(object sender, EventArgs e) { lstChatters.Items.Clear(); NickDialog nickDlg = new NickDialog(); if (nickDlg.ShowDialog() == DialogResult.OK) { myNick = nickDlg.txtNick.Text; nickDlg.Close(); } txtMessage.Focus(); Application.DoEvents(); InstanceContext site = new InstanceContext(this); proxy = new ChatProxy(site); IAsyncResult iar = proxy.BeginJoin(myNick, new AsyncCallback((thisIar) => { try { string[] list = proxy.EndJoin(thisIar); pwDlg.Invoke((Action)(() => { if (list == null) { pwDlg.ShowError("Error: Username already exist!"); ExitChatSession(); } else { pwDlg.Close(); ShowConnectMenuItem(false); foreach (string name in list) { lstChatters.Items.Add(name); } AppendText("Connected at " + DateTime.Now.ToString() + " with user name " + myNick + Environment.NewLine); } })); } catch (Exception ex) { pwDlg.Invoke((Action)(() => { pwDlg.ShowError("Error: Cannot connect to chat!"); ExitChatSession(); })); } }), null); pwDlg = new PleaseWaitDialog(); pwDlg.ShowDialog(); }
/// <summary> /// �����ϱ� /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void connectToolStripMenuItem_Click(object sender, EventArgs e) { InstanceContext site = new InstanceContext(this); proxy = new ChatProxy(site); lstChatters.Items.Clear(); NickDialog nickDlg = new NickDialog(); if (nickDlg.ShowDialog() == DialogResult.OK) { myNick = nickDlg.txtNick.Text; nickDlg.Close(); } txtMessage.Focus(); IAsyncResult iar = proxy.BeginJoin(myNick, new AsyncCallback(OnEndJoin), null); pwDlg = new PleaseWaitDialog(); pwDlg.ShowDialog(); }