void WorkerRefreshConnections(object sender, DoWorkEventArgs e) { // Needed when updating UI elements from outside main thread this.Dispatcher.Invoke((Action)(() => { // Refresh connections conns.Refresh(); ConnectionsDataGrid.Items.Refresh(); // Update summary information UpdateSummary(); })); }
public MainWindow() { InitializeComponent(); //Get list of connections conns = new TCPUDPConnections(); conns.Refresh(); //Set up task that refreshes connection periodically worker = new BackgroundWorker(); worker.DoWork += WorkerRefreshConnections; _timer = new Timer(500); _timer.Elapsed += TimerElapsed; _timer.Start(); ConnectionsDataGrid.ItemsSource = new ObservableCollection <TCPUDPConnection>(conns); }
public TCPUDPConnection GetUDPConnection(EndPoint localEndPoint, EndPoint remoteEndPoint) { udpConnections.Refresh(); return(udpConnections.SingleOrDefault(c => (c.Local?.Equals(localEndPoint) ?? false) && (c.Remote?.Equals(remoteEndPoint) ?? false))); }
public TCPUDPConnection GetTCPConnection(EndPoint localEndPoint, EndPoint remoteEndPoint) { tcpUdpConnections.Refresh(); return(tcpUdpConnections.SingleOrDefault(c => c.Local.Equals(localEndPoint) && c.Remote.Equals(remoteEndPoint))); }