Fail to update chart in UI thread
Posted: Fri Jul 25, 2014 9:30 am
Hi
I am using a WorkerThread to load data from a text file. Once the loading completes, a handler in the xxx.xaml.cs file will be invoked. In the handler, i used lightningchart.Dispatcher.CheckAccess() to check whether the current thread owns the control. Seems like it is not, thus i used the dispatcher instead.
lightningchart.Dispatcher.Invoke((Action)(() =>
{
drawChart();
}));
void drawChart()
{
lightningchart.BeginUpdate();
// my codes to update the chart.
lightningchart.EndUpdate();
}
Inside the drawChart() function, i tried to set the title of the chart, set the x-axis range, etc., but it doesn't get updated into the chart. Any idea why? If I do not have the WorkerThread, there is no issue.
Thanks!
I am using a WorkerThread to load data from a text file. Once the loading completes, a handler in the xxx.xaml.cs file will be invoked. In the handler, i used lightningchart.Dispatcher.CheckAccess() to check whether the current thread owns the control. Seems like it is not, thus i used the dispatcher instead.
lightningchart.Dispatcher.Invoke((Action)(() =>
{
drawChart();
}));
void drawChart()
{
lightningchart.BeginUpdate();
// my codes to update the chart.
lightningchart.EndUpdate();
}
Inside the drawChart() function, i tried to set the title of the chart, set the x-axis range, etc., but it doesn't get updated into the chart. Any idea why? If I do not have the WorkerThread, there is no issue.
Thanks!