private async void ThreadPoolCheckVersion(object obj) { System.Threading.Thread.Sleep(100); MqttSyncClient mqtt = new MqttSyncClient(new MqttConnectionOptions( ) { IpAddress = "118.24.36.220", Port = 1883, UseRSAProvider = true, }); OperateResult <string> read = await mqtt.ReadRpcAsync <string>("SupportList/GetDeviceSupport", new { token = string.Empty, unique = this.formName }); if (read.IsSuccess) { if (!string.IsNullOrEmpty(read.Content)) { List <DeviceSupportList> devices = JArray.Parse(read.Content).ToObject <List <DeviceSupportList> >( ); Invoke(new Action <List <DeviceSupportList> >(RenderDevice), devices); } } else { MessageBox.Show("Request Server failed: " + read.Message); } }
private async void button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.textBox1.Text)) { MessageBox.Show("Model can't be null!"); return; } button1.Enabled = false; MqttSyncClient mqtt = new MqttSyncClient(new MqttConnectionOptions( ) { IpAddress = "118.24.36.220", Port = 1883, UseRSAProvider = true, }); OperateResult <List <DeviceSupportList> > read = await mqtt.ReadRpcAsync <List <DeviceSupportList> >("SupportList/UploadSupport", new { token = string.Empty, unique = this.formName, model = this.textBox1.Text, qq = this.textBox2.Text, name = this.textBox3.Text }); if (read.IsSuccess) { MessageBox.Show("Upload data success"); System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(ThreadPoolCheckVersion), null); } else { MessageBox.Show("Request Server failed: " + read.Message); } button1.Enabled = true; }