/// <summary> /// the thread to populate the list /// </summary> /// <param name="mvp">this manager overview page</param> public void PopulateListThread(ManagerOverviewPage mvp) { mvp.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate { UpdateLabel.Content = "Opdaterer..."; })); mvp.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate { LoadingBar.Visibility = Visibility.Visible; })); IEnumerable <IPEndPoint> peerlist = _ui.GetPeerlist(); if (peerlist != null) { var dataSource = (from ip in peerlist where _ui.IsStationActive(ip) select new StationStatus { IpAdress = ip.Address.ToString(), Connected = true }).ToList(); dataSource.AddRange(from ip in _ui.DiscoverPeers() where !peerlist.Contains(ip) select new StationStatus { IpAdress = ip.Address.ToString(), Connected = false }); mvp.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate { ManagerstationGrid.ItemsSource = dataSource; })); mvp.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate { ManagerstationGrid.Items.Refresh(); })); } mvp.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate { UpdateLabel.Content = ""; })); mvp.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate { LoadingBar.Visibility = Visibility.Hidden; })); }