Hi, Are there any examples in the documentation which show how threading with the Chart works?
Specifically, my issue is that I have a long loop which adds "Coordinate" objects to an ObservableCollection which is set as the ItemsSource of some ScatterSeries. Assume that this loop takes minutes to complete, as I add a Thread.Sleep(1000) for each iteration. Importantly, I would like the chart to display each "Coordinate" object as and when it is added to the ObservableCollection, without seizing up the whole chart.
I have followed some examples of creating a Dispatcher, however this appears to have no effect. Example code of what I am trying to achieve:
Thanks for any help in advanced!
Specifically, my issue is that I have a long loop which adds "Coordinate" objects to an ObservableCollection which is set as the ItemsSource of some ScatterSeries. Assume that this loop takes minutes to complete, as I add a Thread.Sleep(1000) for each iteration. Importantly, I would like the chart to display each "Coordinate" object as and when it is added to the ObservableCollection, without seizing up the whole chart.
I have followed some examples of creating a Dispatcher, however this appears to have no effect. Example code of what I am trying to achieve:
private ObservableCollection<Coordinate> coordinates = new ObservableCollection<Coordinate>();private Queue<Coordinate> coordinatesQueue = new Queue<Coordinate>();private void FillQueue(){ . . .}private void UpdateChart(){ SomeScatterSeriesinChart.ItemsSource = coordinates; this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate() { while (coordinatesQueue.Count != 0) { coordinates.Add(coordinatesQueue.Dequeue()); Thread.Sleep(1000); } } );}Thanks for any help in advanced!