I have a WPF application that is connected to a USB device. Said device raises an event at a rate of about 10/second. The data from these events updates a bar chart and a line chart. The bar chart represents the data from each event as they occur. The line chart is used to show values over time and is read from a collection of historical values from the start of the measurement.
My issue is, after about 3-5 minutes of measurements, the UI becomes very slow and eventually unresponsive. I think it is due to the below code snippet occurring too often and eventually locking up the UI thread.
System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
Update the collection here.
}));
Is there a better way to update the collection so as to not lock up the UI?