public void UpdateAdapterList() { if (flowLayoutPanel1.InvokeRequired) { ThreadStart ts = new ThreadStart(UpdateAdapterList); flowLayoutPanel1.Invoke(ts); } else { if (flowLayoutPanel1.Controls.Count == 0) { foreach (NetworkAdapter na in NetworkAdapter.GetAllAdapters()) { AdapterDisplay ad = new AdapterDisplay(new AdapterInfo(na.Pointer, na.Name, na.InterfaceInformation, na.InBandwidth, na.OutBandwidth, na)); ad.Width = flowLayoutPanel1.Width - 5; flowLayoutPanel1.Controls.Add(ad); } } else { foreach (AdapterDisplay ad in flowLayoutPanel1.Controls) { ad.Update(); } foreach (NetworkAdapter na in NetworkAdapter.GetNewAdapters()) { AdapterDisplay ad = new AdapterDisplay(new AdapterInfo(na.Pointer, na.Name, na.InterfaceInformation, na.InBandwidth, na.OutBandwidth, na)); ad.Width = flowLayoutPanel1.Width - 5; flowLayoutPanel1.Controls.Add(ad); } } } }