Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7818771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:41:34+00:00 2026-06-02T06:41:34+00:00

I’ve got a WPF application. Most of the time, the app uses almost no

  • 0

I’ve got a WPF application. Most of the time, the app uses almost no CPU. This is good. But I have this one window that pops up under specific circumstances. According to the performance analyses I’ve run in Visual Studio, my code isn’t using alot of CPU, the Application.Run method is. And most of that is in “Functon Body”. To the tune of like 40-50% of the CPU.

How do I figure out what’s using up the CPU? I’ve got some animations using key frames that animate the color of some things. I’m wondering if they’re what’s eating up the CPU. I know I can remove them temporarily, and I just might, but is there another way to figure out exactly what’s eating the CPU?

Tony

PS: To prove to myself it was the animations, I watched the CPU usage of my program in Task Manager. It was about 0 before the window with the animations was displayed. The window displayed & the CPU went up. I then pushed a button which changes the state of the data & has the side effect of stopping the animations. The CPU went back down to 0. I repeated this a few times with consistent results. Looks like it’s the animations to me. Though there is a possibility of it being something else that is also going on at the same time as the animations.

The animations are key frame animations intended to simulate a flashing light. I’m going to dump the key frame animations and just swap the fill brush color between two colors using a timer.

PS: If anyone is interested, I did a little research into WPF animation and I found out that there are at least 2 different Color Animation KeyFrame classes in WPF. The one I was using, LinearColorKeyFrame, continuously varies the color from whatever it is to whatever you want to be over the duration of the animation. The other is DiscreteColorKeyFrame. This instantly changes the color from whatever it is to whatever you want it to be.

So I edited my animation from this:

<Storyboard x:Key="FlashingStoryboard" AutoReverse="True" RepeatBehavior="Forever">
    <ColorAnimationUsingKeyFrames BeginTime="00:00:00" 
                                  Storyboard.TargetName="Flasher" 
                                  Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
        <LinearColorKeyFrame KeyTime="00:00:00.5" 
                             Value="{Binding Path=FlashColor, RelativeSource={RelativeSource AncestorType={x:Type local:Flasher}}}"/>
    </ColorAnimationUsingKeyFrames>
    <DoubleAnimation Duration="00:00:00.5" 
                     From="0" To="10" 
                     Storyboard.TargetName="FlasherBlur" 
                     Storyboard.TargetProperty="Radius">
    </DoubleAnimation>
</Storyboard>

To this:

<Storyboard x:Key="FlashingStoryboard" AutoReverse="True" Duration="00:00:00.5" RepeatBehavior="Forever">
    <ColorAnimationUsingKeyFrames BeginTime="00:00:00" 
                                  Storyboard.TargetName="Flasher" 
                                  Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
        <DiscreteColorKeyFrame KeyTime="00:00:00.25"
                               Value="{Binding Path=FlashColor, RelativeSource={RelativeSource AncestorType={x:Type local:Flasher}}}" />
    </ColorAnimationUsingKeyFrames>
</Storyboard>

The new animation uses a lot less CPU. It turns out that most of the CPU usage being hogged by the DoubleAnimation, which was producing a glowing effect. It used up almost 1/2 of the CPU! Not worth it at all. Even when I removed that, the CPU usage was still averaging about 15%. Switching it to a DiscreteKeyFrame brought it down under 10%.

There was another, similar animation animating a border around items in a ListBox in the same window. I made the same changes and now the CPU usage is acceptable. I’m not exactly sure what it is, but it’s way better than it was.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T06:41:36+00:00Added an answer on June 2, 2026 at 6:41 am

    yep, animation, is the first thing that anyone will tell you. also how big is it? Is it non stop? relatively big chunk of the screen then yeah!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.