![](/s/cache/b7/bf/b7bfbef57285c1bfe46884a06b9f8918.png)
+3
Under review
Thread safety and RenderPoints
So I've seen the error a few times, mainly when the plot is trying to update and data is being added to the series:
> System.InvalidOperationException occurred
> HResult=-2146233079
> Message=Collection was modified; enumeration operation may not execute.
> Source=mscorlib
> StackTrace:
> at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
Seems to be because ICollection is being used here:
https://github.com/oxyplot/oxyplot/blob/develop/So...
Would it be better to use one of the concurrent collects for this?
> System.InvalidOperationException occurred
> HResult=-2146233079
> Message=Collection was modified; enumeration operation may not execute.
> Source=mscorlib
> StackTrace:
> at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
Seems to be because ICollection is being used here:
https://github.com/oxyplot/oxyplot/blob/develop/So...
Would it be better to use one of the concurrent collects for this?
Customer support service by UserEcho
The main reason I brought up using Concurrent Collections over normal collections is because I'm using OxyPlot currently for real time data, so it's always possible the chart will be updated (from either the set interval or any of the calls that update it, like show or hiding a series, in this event for example) as data is being added into the series on it.
I didn't even know this SyncRoot property existed, I'll look at it more and let you know, Thanks!
Just some remarks on this
I was running into this error this with Xamarin.Android OxyPlot 1.0
The plot is being redrawn / invalidated at 40Hz. This is working fine with SyncRoot.
But I discovered that when I tap on the plot, I get the "Collection was modified; enumeration operation may not execute" exception. Interesting because I had disabled all touch interactions but looks like OxyPlot still try and process the touch and do something with the collection
The problematic code that was causing the exception was
Fixed by moving points collection to inside SyncRoot area.
My guess is that the touch interaction on the plot view somehow interacted with the Points collection in the background, and of course updating the plot at 40Hz made this problem pretty obvious.
Ah. I missed setting selectable to false for series.
Doing this
Also resolved the issue.