InvalidOperationException

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
mattmobilemedtek
Posts: 28
Joined: Tue Sep 30, 2014 8:06 pm

InvalidOperationException

Post by mattmobilemedtek » Tue Mar 10, 2015 5:58 pm

I seem to be getting a random InvalidOperationException in RenderDeviceDirectX.cs on line 11000 foreach (DrawDataDirectX dd in listDD) with the message "Collection was modified; enumeration operation may not execute"

I am also getting a random ArgumentException in the same method only a few lines down in the Array.Copy method.

I'm thinking it's a threading issue. I have 3 graphs that I'm updated simultaneously. I was originally calling BeginUpdate on all 3, making changes to all 3 and then calling EndUpdate on all three. I then saw in the examples where you would update multiple graphs sequentially instead. So I did that and the issue is still occurring. Is this something that you have seen before?

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: InvalidOperationException

Post by ArctionPasi » Wed Mar 11, 2015 7:28 am

"Collection was modified" is a very typical error when using background threads and you forget to use Dispatcher.Invoke when updating the chart from the thread. The thread's code changes a series list or other collection while chart is rendering itself. Please make sure you are using Dispatcher.Invoke correctly.
LightningChart Support Team, PT

mattmobilemedtek
Posts: 28
Joined: Tue Sep 30, 2014 8:06 pm

Re: InvalidOperationException

Post by mattmobilemedtek » Wed Mar 11, 2015 1:35 pm

I reviewed my code and found that I'm using Dispatcher.Invoke the same way it is used in the example ExampleThreadMultiChannel.xaml.cs. I'm thinking I might be doing too much inside the refreshCharts method.

Post Reply