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
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!