private void show_ping() { Configuration c = controller.GetConfiguration(); for (int i = 0; i < listViewServerBox.Items.Count; i++) { //Console.WriteLine("1: " + Convert.ToString(i)); string ip = c.configs[i].server; int port = c.configs[i].server_port; my_param m = new my_param(); m.i = i; m.ip = ip; m.method = 0; Thread t = new Thread(new ParameterizedThreadStart(inthread)); t.Start(m); my_param mm = new my_param(); mm.i = i; mm.ip = ip; mm.port = port; mm.method = 1; Thread tt = new Thread(new ParameterizedThreadStart(inthread)); tt.Start(mm); } }
private void inthread(object obj) { my_param o = (my_param)obj; if (o.method == 0) { string ip = Utils.getIp(o.ip); if (ip == "no ip") { string resp = "no ip"; if (this.IsHandleCreated) { listViewServerBox.BeginInvoke(new treeinvoke(() => { listViewServerBox.Items[o.i].SubItems[1].Text = resp; })); } else { return; } } else { string resp = Utils.ping_example_3(o.ip); if (this.IsHandleCreated) { listViewServerBox.BeginInvoke(new treeinvoke(() => { listViewServerBox.Items[o.i].SubItems[1].Text = resp; })); } else { return; } } } else if (o.method == 1) { string ip = Utils.getIp(o.ip); if (ip == "no ip") { string resp = "no ip"; if (this.IsHandleCreated) { listViewServerBox.BeginInvoke(new treeinvoke(() => { listViewServerBox.Items[o.i].SubItems[2].Text = resp; })); } else { return; } } else { string resp = Utils.tcping_3(o.ip, o.port); if (this.IsHandleCreated) { listViewServerBox.BeginInvoke(new treeinvoke(() => { listViewServerBox.Items[o.i].SubItems[2].Text = resp; })); } else { return; } } } }