CompositionTarget.Rendering can be a CPU hog

I ran into an issue where my WPF application would consume about 20% of CPU time just sitting idle on a Page. A question from Tim Sneath led me to investigate an aspect of the app that uses the CompositionTarget.Rendering callback to do some animations that can’t be done in other ways in WPF right now.

I had several UIElements that each had the Rendering event hooked up, and the code in the event handler would do next to nothing most of the time, since the animation only was kicked off on a mouse up event. I modified the code, so that the event hookup doesn’t happen until the mouse up event comes in, and also so that an unhook happens when the animation is finished. This promptly took down the CPU load to the typical intermittent 1-2%.

2 Comments

  1. Pingback: PresentationSource - RSS It All

  2. Pingback: GeekTieGuy » Inside the HP TouchSmart PC software: HP SmartCenter - Part 2

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.