约30分钟后,我的WPF应用程序使用高CPU使用率,然后我打破了应用程序,找出哪些代码花费高CPU使用率,但我什么都没有。如何减少WPF应用程序的CPU使用率?
Visual Studio 2008中不能显示当前运行的代码,但我发现这个在“调用栈”面板:
[In a sleep, wait, or join] mscorlib.dll!System.Threading.WaitHandle.WaitAny(System.Threading.WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext) + 0x8f bytes System.dll!System.Net.TimerThread.ThreadProc() + 0x2f9 bytes mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) + 0x66 bytes mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x6f bytes mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x44 bytes
这是什么?高CPU使用率有什么问题? 以及如何降低CPU使用率?
我使用性能剖析了WPF工具来发现哪些事件或元素采取的CPU使用率很高,后来我们发现:蜱(TimeManager.Tick())是大约40%的CPU使用率的应用程序。哪些事件会调用TimeManager.Tick?如何减少它? – 2009-05-12 06:44:05