Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.0k views
in Technique[技术] by (71.8m points)

windows - Why are : visible, control assigned TActions affecting the CPU usage of the application?

If a TAction is linked to an Object such as TToolButton( Item of TToolBar ) or TActionClientItem( Item of TActionToolBar ) and that Object is visible on runtime, then whenever you move the mouse in the form (anywhere but the Toolbars), there seems to be extra load being done on the CPU based on the number of visible TActions, that is in comparison to moving the mouse when none of the TAction linked Items are visible on either of the previous mentioned bars.

It's obvious that the noticeable % of extra load done is completely based on what kind of a rig you are running but what I have noticed is that the actual difference can be significant when you have an application with :

  • a lot of visible TAction linked items
  • a custom component that already performs minor calculations for onMouseOver Events such as changing the appearance of the control
  • a custom Visual Style

So the question is why do visible item linked TAction components affect the processing of mouse movement?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The design of actions is based on idle time updating of actions. As you move your mouse, the application receives lots of queued messages. Each time the queue is emptied, the application is deemed to be idle, and all the actions are updated. And this can lead to high CPU utilization.

This issue is well known and acknowledged in the VCL. For example, take a look at TApplication.ActionUpdateDelay.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...