GUI启用/禁用它的样式不好吗? [英] GUI enable/disable Is it bad style?

查看:99
本文介绍了GUI启用/禁用它的样式不好吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
很多时候,我确实根据系统状态启用/禁用"OnIdle"中的GUI元素(我知道,这绝对不是确定状态消耗CPU的方式).

我越来越觉得这是一种懒惰的方式,对此我感到不满意.

有人可以确认这是一种不好的技术吗?如果是,哪种方法更好?

非常感谢.
关于

Hello all
A lot of times I do enable/disable GUI elements in "OnIdle" according to the systems state (I’m aware, this is definitively not the way if determine the state costs CPU).

More and more I feel this is a lazy way and I become unhappy with this.

Can somebody confirm that this is a bad technique? If yes what is the better way?

Thanks a lot.
Regards

推荐答案

是和否.至少它并不明显不好并且被广泛使用.这取决于您如何使用它.不看细节就很难说.

最佳技术是懒惰的:它们的基础知识可能很复杂,但临时使用却是懒惰的.他们不应该需要大量无聊的计算,而恰好是应用程序开发人员的人也不需要太多的关注.

现在,仅当您使用惰性模式时,惰性方法才应该是好的.在这种情况下,如果您不触摸键盘和鼠标,则系统什么也不会发生.如果这是不正确的,也就是说,如果UI周期性地发生某些事情,那肯定是不好的.状态检查周期可能过多;并且您应该在CPU使用率上做到切合实际:单击一次时发生的事情,额外的毫秒数不计算在内.

最好的技术应该像这样工作:

您可以具有一些UI范围的StateDirty标志.单个控件的更改应将此标志设置为true,并发送UI范围的消息,该消息应触发完整的状态更新周期.如果周期过长并且通常不会更改所有内容,那也不错,因为额外的毫秒数不算在内.但是,如果在没有用户干预的情况下定期发生这种情况,那将是可以接受的.如果没有任何干扰,UI应该100%休眠.

—SA
Yes and no. At least it is not obviously bad and widely used. It depends how you use it. It''s hard to say without seeing the detail.

Best techniques are lazy: they can be sophisticated in fundamentals but lazy in ad-hoc usage; they should not require a lot of boring calculations and too much attention from a human being who happened to be an application developer.

Now, you lazy approach should be good only if you use the lazy pattern. In this case, nothing should happen to the system if you don''t touch keyboard and mouse. If this is not true, that is, if something happens to the UI periodically, this certainly cannot be good. The state check cycle could be excessive; and you should be realistic in CPU usage: when something happens on one click, an extra millisecond does not count.

The best technique should work like this:

You can have some UI-wide StateDirty flag. A change in a single control should set this flag to true and send a UI-wide message which should trigger the full state update cycle. It''s no too bad if the cycle is too excessive and often does not change everything, because an extra millisecond does not count. But it would be be acceptable if this happens periodically without user intervention. The UI should 100% sleep if nothing disturbs the system.

—SA


这篇关于GUI启用/禁用它的样式不好吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆