# Speed up RemoveAllOverlayObjects?

**URL:** <https://forum.commonvisionblox.com/t/speed-up-removealloverlayobjects/84>\
**Category:** C-style API\
**Tags:** display, activex, overlayplugin\
**Created:** [May 16, 2017, 11:19am UTC](https://forum.commonvisionblox.com/t/speed-up-removealloverlayobjects/84 "2017-05-16T11:19:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![GaunterODim](https://avatars.discourse-cdn.com/v4/letter/g/ed655f/32.png) [@GaunterODim](https://forum.commonvisionblox.com/u/GaunterODim)\
**Post date:** [May 16, 2017, 11:19am UTC](https://forum.commonvisionblox.com/t/speed-up-removealloverlayobjects/84/1 "2017-05-16T11:19:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![illusive](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/illusive/32/61_2.png) [@illusive](https://forum.commonvisionblox.com/u/illusive)\
**Post date:** [May 16, 2017, 1:10pm UTC](https://forum.commonvisionblox.com/t/speed-up-removealloverlayobjects/84/2 "2017-05-16T13:10:14Z")

</div>

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.
