The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,262 other subscribers

Updating Actions (Don’t Do This) – Dave’s Development Blog

Posted by jpluimers on 2020/05/13

I remember fixing a high CPU toggling the Enabled property in an OnUpdate even handler on a TCustomAction descendant quite some time ago, but wasn’t completely sure of the exact cause.

My fix was to only set it once every clock tick (about every 20 milliseconds).

The best fix would have been not to toggle at all: just calculate the right result, then only set the Enabled property once: [WayBack] Updating Actions (Don’t Do This) – Dave’s Development Blog

–jeroen

2 Responses to “Updating Actions (Don’t Do This) – Dave’s Development Blog”

  1. SilverWarior said

    Doesn’t changing the Enabled property fire the OnUpdate event in the first place? So changing Enabled property inside OnUpdate event method could teoretically lead to infinite loop.

    • jpluimers said

      I’m not sure. During my fight with rectum cancer, I will hardly do any Delphi stuff at all.

      So if you have more time/energy: please check out and report back.

      Thanks in advance!

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.