WS_EX_COMPOSITED - 高CPU [英] WS_EX_COMPOSITED - high CPU
问题描述
我在我的应用程序中使用WS_EX_COMPOSITED样式,但它运行CPU到100%,有办法停止我的应用程序绘图一段时间,并恢复只有当我需要?
有些人建议使用睡眠,但是在WndProc什么时候睡觉?
I am using WS_EX_COMPOSITED style in my application but its running the CPU to 100%, is there way to stop my application drawing for a while and to resume only when i need ? Some people are suggesting to use Sleep's but where exactly in WndProc do i put sleeps ?
提前感谢。
推荐答案
不要使用 Sleep
。这是几乎没有问题的解决方案。
Don't use Sleep
. It is the solution to almost no problems.
真的, WS_EX_COMPOSITED
可以占用CPU,经验。 Vista和更高的性能影响要小得多。但是,如果你的应用程序是空闲的,那么它不会重画。如果你的CPU是100%,应用程序是空闲的,那么你在你的 WM_PAINT
处理中做错了。你的描述听起来像一个无尽的油漆循环。如果你做正确的事情,这不会发生,即使你使用 WS_EX_COMPOSITED
。
It's true that WS_EX_COMPOSITED
can hog CPU but mostly on XP in my experience. There is a much less significant performance hit on Vista and up. However, if your app is idle then it won't be repainting. If your CPU is 100% and the app is idle then you are doing something wrong in your WM_PAINT
handling. What you describe sounds like an endless loop of paint cycles. If you do things right, that won't happen, even if you use WS_EX_COMPOSITED
.
双向缓冲方式, BeginBufferedPaint
是现代化的方式,在Vista及以上。
As regards the right way to do double buffering, BeginBufferedPaint
is the modern way to do this, on Vista and up.
这篇关于WS_EX_COMPOSITED - 高CPU的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!