I have a graphics layer that has many Graphics on it. This graphics may change depending on clients selection. Since it takes some time to recreate the graphics and add them to the layer, I thought it would be nice to just recreate the layer in a different thread, return it in the WorkItem of the thread that did the work and replace it in the map. When I try to add the new layer to the Map though I get this error:The calling thread cannot access this object because a different thread owns itTo try to solve this problem, I used the dispatcher of the Map like this:
map1.Dispatcher.Invoke((Action)
(()=>{
map1.Layers.Add(layerCreatedInOtherThread);
})
);
And I got the same error. I also tried BeginInvoke and got the same result... So, basically the map cannot use that layer created in a different thread. How can I do this? Any suggestions?