I keep getting a crash in ListFiller:Fill

Sep 18, 2013 at 2:30 PM
I keep getting random crashed in the Fill function in ListFiller.cs. I get the Collection was modified; enumeration operation may not execute error on IEnumerable source in the foreach (var sourceItem in staticSource) line.

I have had other similar problems within the rest of the library, where because I update datasets quite often, obviously before the last has been written to screen, the array has been updated before it has finished iterating through it! Normally, casting ToArray() // ToList() has solved this.
Sep 20, 2013 at 7:18 AM
Edited Sep 20, 2013 at 7:18 AM
Is this problem solved when you use ToArray/ToList in your application?
I would like to avoid adding this to OxyPlot, as I guess there may be a performance hit for large datasets.

Can we lock the collection's syncroot while updating the plot?
Sep 20, 2013 at 7:29 AM
It has been solved where I've used it in other places, but obviously can't here.
I'll have a look at syncroot, thanks.
Oct 7, 2013 at 12:02 PM
The way I seem to have solved this was my using a ConcurrentQueue instead of a List as my ItemsSource. ConcurrentQueue's are thread safe and so have avoided the issue where the ItemsSource was getting updated whilst that function was looping. I think if I had implemented the same thing throughout my application then maybe I wouldn't have needed to do any ToArray's. Hopefully if I have time i'll go back and undo all of that - as you say, large datasets maybe hit and I do have HUGE datasets. Maybe something to look at in your tutorials? ConcurrentQueue's are no harder to implement than lists but are thread safe :-)
Mar 13, 2015 at 7:25 AM
ConcurrentQueue !! Thank you!! it works perfectly!!