Anyone familiar with the MapFrame.cs code?

Developer
Mar 11, 2011 at 5:52 PM

I have been playing around with the new Task Parallel Library available in .Net 4.0 to see if I could speed up some of the drawing code, specifically replacing some of the foreach loops in the MapPolygonLayer class.  In the process I noticed that a lot if this drawing code get called twice.  A complex cascade of events gets triggered when adding and removing layers.  I have been looking through the code but can't figure out if this is by design or a bug.  We might be able to cut the drawing time in half if this is a bug.

Thanks,

Kurt

Developer
Mar 11, 2011 at 8:41 PM

Hi Kurt,

On the layer collection there are methods to Suspend/Resume events.  You can use that to keep from getting the updates when changing the layers collection.  For my application, I've suspended those events permanently, because I was still getting undesired updates.  If I remember correctly, calling Resume triggers an update if anything changed since the last Suspend.  Not sure what the consequences of keeping the events suspended, but I've not noticed any problems with it.  You just have to remember to Refresh the map after modifying the layer collection.

I don't know what the correct improvement should be here for Dot Spatial at large, but it seems the layer collection event logic could use some reengineering.

HTH,

Kyle