private async void button1_Click(object sender, EventArgs e) { var res = await ClientManager.NewAsync().Get <ServerMethods>().LogOn(this.textBox1.Text); var isOK = res?.First?.Value <bool>(); if (isOK != null) { if (isOK.Value) { this.BeginInvoke(new EventHandler(delegate { this.Close(); })); } else { MessageBox.Show(res[1].Value <string>()); } } }
private async void button1_Click(object sender, EventArgs e) { if (this.comboBox1.SelectedIndex == 0) { ClientManager.Sync.Get <ServerMethods>().SendMessageToAllUser(this.textBox1.Text); } else { var userinfo = this.comboBox1.SelectedItem as UserInfo; if (userinfo != null) { var msgres = await ClientManager.NewAsync().Get <ServerMethods>().SendMsgToUser(userinfo.UserName, this.textBox1.Text); var msg = msgres?.First?.Value <string>(); this.BeginInvoke(new EventHandler(delegate { this.richTextBox1.AppendText((userinfo.UserName + ":" + msg ?? "发送失败") + "\r\n"); })); } } }