Speed up RemoveAllOverlayObjects?

I have a display on which I use several instances of the cross hair plug in to mark the positions of objects my classifier has found. In some cases there can be hundreds of them, and deleting them (RemoveAllOverlayObjects) takes suprisingly long, in some cases close to a second, which is too long.

There are two things that might help speed the removal of your overlay plugins up:

  1. Use ManualDisplayRefresh. If you set this property to true before calling RemoveAllOverlayObjects and back to its initial value once the RemoveAllOverlayObject call returned you might experience a notable speedup already as this is going to suppress a number of unnecessary repaints. You might need to call Refresh() afterwards to make sure the display is up-to-date.
  2. If you don’t have to worry about other types of overlay objects (labels and user objects), then you might as well use RemoveAllOverlays - this function contains a shortcut that’ll remove all available overlay objects in one go with as little overhead as reasonably possible.

The reason why RemoveAllOverlayObjects cannot be made as quick as RemoveAllOverlays is that in the CVCDisp.dll both, overlay plugins and user objects, are mapped to the same type of overlay. This makes going through the list of currently used objects in the display control more time-consuming because for each entry the actual object type has to be deduced.