private void button3_Click(object sender, EventArgs e) { Dictionary <string, IPEntity> tempIPList = new Dictionary <string, IPEntity>(); tempIPList.Add("10.10.64.39", null); tempIPList.Add("10.10.64.157", null); tempIPList.Add("10.10.64.172", null); foreach (var key in tempIPList.Keys) { IPEntity ipEntity = new IPEntity(key, DateTime.Now); ipEntity.ComputerName = ipEntity.GetHostName(key); ipEntity.MacAddr = ipEntity.GetMacBySendARP(key); textBox1.Text += ipEntity.ToString() + "\r\n"; } }
public void ThreadPoolMethod(object obj) { //TODO: Add your code here object[] objs = (object[])obj; int index = (int)objs[0]; string IPAddr = IPList[index]; IPEntity ipEntity = IPEntities[IPAddr]; if (ipEntity == null) { ipEntity = new IPEntity(IPAddr, DateTime.Now); ipEntity.ComputerName = ipEntity.GetHostName(IPAddr); ipEntity.MacAddr = ipEntity.GetMacBySendARP(IPAddr); if (ipEntity.ComputerName != "" && ipEntity.MacAddr != "00-00-00-00-00-00") { ipEntity.Status = true; } IPEntities[IPAddr] = ipEntity; } else { ipEntity.ComputerName = ipEntity.GetHostName(IPAddr); ipEntity.MacAddr = ipEntity.GetMacBySendARP(IPAddr); if (ipEntity.ComputerName != "" && ipEntity.MacAddr != "00-00-00-00-00-00") { ipEntity.Status = true; ipEntity.LastOnline = DateTime.Now; } else { ipEntity.Status = false; } IPEntities[IPAddr] = ipEntity; } //UpdateUI((int)objs[0]); ManualResetEvent e = (ManualResetEvent)objs[1]; e.Set(); }