Hello,
I have a XamDataChart that I put a lot of series (10-50) in with plenty of points in for each (500-1.000) and understandably it takes a while to render. While I generate the data I have a XamBusyIndicator showing. I can't use the following code on a worker thread:
foreach (ScatterSplineSeries ser in sps) { dataChart.Series.Add(ser); }
because dataChart is not owned by it. What I want to know is if there is a way to put the data in there (probably from the gui thread) and then continue displaying the busyindicator while the datachart is loading.
Thanks.
The main performance bottleneck here is in the WPF rendering stack / visual tree, so there's nothing that can be handled as a background operation. Putting busy indicators on a second UI thread is possible using VisualTargetPresentationSource. This is difficult to implement, but it could be the solution you're looking for.
Going back to the chart, adding the series must happen on the UI thread. However, this can be made more bearable by time-slicing. Consider this code: http://pastebin.com/y9QXtAiL
Some other things that might help are setting the Series.MarkerTemplate to something simpler than the default, avoiding Bindings as much as possible, and using Series.UseLightweightMarkers. UseLightweightMarkers will skip the measure and offset operations, so your makers will not be centered-- however, this can be remedied by using fixed size markers with negative margins.
Hello David,
Thank you for your immediate response. What I ended up doing is keeping the series adding to the UI thread (just like you said above) but added a call like the following:
Dispatcher.Invoke(new Action(() => { }), System.Windows.Threading.DispatcherPriority.ContextIdle);
after every addition. That, coupled with the busy indicator, worked since the UI is updating on every step. Now, this doesn't solve the fact that the UI is unresponsive during that time (no button clicks etc.) but at least the user knows that the program is not stuck and it's just working.
Thanks again.