I am developing a C# application, where I get USB data every 1 millisecond and my application has a data grid which is intended to display these frames as soon as its received. My problem here is since data rate is too high my grid stops or application freezes after 10-15 seconds of launching. I have created separate thread to handle this displaying part even though it does'nt help me. Is the data grid capable enough to display data at 1ms rate? Should I use some other way to make it working? Any help, hints or suggestion would be of great help. Thank you.
Code: The gui() function is made as thread and datatable is passed as a parameter. The data which is received by the driver underneath adds the data to datatable and then passed as a param for gui() funtn.
public static DataView dataview = new DataView();
public static void gui(DataTable dt)
{
try
{
if (dt != null)
{
lock (Lock)
{
Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(delegate()
{
main.dgUsers.ItemsSource = null;
dataview = dt.DefaultView;
main.dgUsers.ItemsSource = dataview;
main.dgUsers.Items.Refresh();
//For auto scroll through the data grid
if (main.dgUsers.Items.Count > 0)
{
var border = VisualTreeHelper.GetChild(main.dgUsers, 0) as Decorator;
if (border != null)
{
var scroll = border.Child as ScrollViewer;
if (scroll != null) scroll.ScrollToEnd();
}
}
}));
}
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}