WPFOxyPlot crash on DataPointSeries addPoint

Oct 25, 2011 at 5:52 PM

When using a thread to update the pointseries and a dispatcher to redraw the plot the System systematically crashes after few iterations.

 

in the  thread worker

public void Worker()

{

wile(true)

 {

  double x = counter * 0.1;                           

pointList.Add(new DataPoint(x, Math.Cos(100 * x * Math.PI / 180)));                           

counter++;

  object retVal = Dispatcher.BeginInvoke(new ThreadStart(() => Update()), DispatcherPriority.Normal, null);

Thread.Sleep(10);

}

}

 

private void Update()

{

  oxyPlot.RefreshPlot(true);

 

 

Any Suggestion?

 

Thanks to anybody

Oct 25, 2011 at 7:57 PM

did you try a lock on your plot model when you modify the points and when you refresh the plot?

Oct 25, 2011 at 8:47 PM

Yes,

i have already did that. 

A lock in the update method and a lock in the worker

Same error in :

DataPointSeries.cs 

Line 319 

   foreach (var o in itemsSource)               

InvalidOperationException : the enumerator has been reset

 

Thx