public void addResult(string imagePath) { if (this.InvokeRequired) { AddResultDelegate ard = new AddResultDelegate(addResult); object[] parameters = { imagePath }; this.Invoke(ard, parameters); } else { imageListView1.Items.Add(imagePath); } }
private void CheckComputer(Object obj) { string ip = obj as string; AddResultDelegate d = new AddResultDelegate(AddResult); try { Ping ping = new Ping(); PingReply reply = ping.Send(ip); if (reply.Status == IPStatus.Success) { listBoxStatus.Invoke(d, "IP地址:" + ip + "状态:扫描成功!"); } else { listBoxStatus.Invoke(d, "IP地址:" + ip + "状态:扫描失败!"); } } catch { listBoxStatus.Invoke(d, "IP地址:" + ip + "状态:扫描失败!"); } }
public void addResult(string imagePath) { if (this.InvokeRequired) { AddResultDelegate ard = new AddResultDelegate(addResult); object[] parameters = { imagePath}; this.Invoke(ard, parameters); } else { imageListView1.Items.Add(imagePath); } }