Here is another performance trick for the Topobase developers.
Let’s imagine the following use case: you have some code which modifies several features, one after the other. No matter if you insert or update them. When you execute this code within Topobase Client, you will recognize that the map is automatically regenerated. This is very handy, because you don’t have to care about the graphic refresh, Topobase does that for you.
The only problem might be that the graphic regenerates itself too often, namely after each modification of a feature.
The question is, how can we suppress the regeneration for a certain time?
It’s straight forward and easy to implement, you only need one line of code.
The following example will lead into several regenerates in the graphic:
foreach (Feature feature in featureList)
{
feature.Attributes[dateCreated].Value = DateTime.Now;
fc.UpdateFeature(ref feature);
}
The following, improved example suppresses the regeneration until all the features have been updated:
using (MapDrawBurst mapBurst = this.Document.Map.InitiateDrawBurst())
{
// the operations inside this using-block won't result
// in regenerating the map.
foreach (Feature feature in featureList)
{
feature.Attributes[dateCreated].Value = DateTime.Now;
fc.UpdateFeature(ref feature);
}
} // the map will be regenerated here (in the Dispose() method)
That’s it!