I’m getting this exception when:
I have two InMemoryFeatureLayer which I am adding shapes to. This is running in a background thread. The process is below. Note that when I change the sleep to 1000 (1 second), the exception doesn’t happen. But I need to do refresh quicker than 1Hz for my requirements. Also, I have tried setting the LockLayerMode to both DoNotLock and Lock. Neither fixed the problem.
void BackgroundThread()
{
for(int i=0;i<nPoints;i++)
{
AddShapeToLayer1();
AddShapeToLayer2();
if(i == 0)
{
map.Dispatcher.Invoke(new Action(() => map.ZoomTo(…) }));
}
map.Dispatcher.Invoke(new Action(() => map.Refresh() }));
Thread.Sleep(100);
}
map.Dispatcher.Invoke(new Action(() => map.Refresh() }));
}
Exception - Collection was Modified; enumeration operation may not execute
Hi Ryan,
I created a sample based on the codes but I didn’t get the exception, would you please try the attached sample on your machine and recreated it based on this sample?
Please see the test video online: screencast.com/t/OcK7ffKTLr2
My computer environment:
CPU: i7-2600 3.4GHZ
RAM: 16GB
OS:x64 window 8
I also tested on the other machine, both of them can work fine.
Waiting for your further information.
(We have opened ticket for you and I will update the info on this post in case others might need)
Thanks,
Johnny
DisplayASimpleMapForWPF.zip (11.1 KB)