开发者

Application.Idle causes high CPU usage

I use the Application.Idle event to handle toolbar status (enable/disable) etc. quite extensively. As I'm beta testing Norton AntiVirus 2011, it brought to my attention that my app that I'm developing triggered a high CPU usage warning on at least one CPU. Sure enough, I opened the task manager and watched one of the four CPU's (quad core system) go to near 100%.

I thought Application.Idle was the way to handle things when 开发者_开发技巧the application wasn't performing CPU tasks. Why is Application.Idle spiking the CPU?

Here is how I attach to the event:

AddHandler Application.Idle, AddressOf OnAppIdle

Been using Application.Idle for a long time, never knew it would have this issue.

Using VS 2010 .NET 4

Thank you.


Since you say you are using Application.Idle to handle toolbar status, I would conclude that the code you're running in the Idle event handler is probably generating Windows messages. Which will be processed, and when processing is finished, Application.Idle will be called again, and so on...

You could try reducing the number of messages you generate in your idle handler - perhaps only modifying toolbar status, or whatever you are doing, if it is actually necessary.

If you post the code from the Idle event handler you may get more help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜