Skip to content

CompositionTarget.Rendering and minimized windows

June 22, 2007

[internal mail thread that may be useful to others…please read bottom to top:]

From: Helpful MS Employee 
The CompositionTarget.Rendering event puts us into a mode where we continuously animate. You should unhook at every opportunity.

From: MS Employee 
Actually, I do. Would that be the cause of the observed activity?

(I have a panel class that does a custom animation. I try (half-heartedly) to unhook when the panel gets unloaded, but it doesn’t do anything when the window gets simply hidden.)

From: Helpful MS Employee 
Do you hook the CompositionTarget.Rendering event?

From: MS Employee 
Subject: Help request: WPF app consuming CPU cycles while hidden

Our app seems to do something nontrivial while it’s hidden; we see a constant 3~4% CPU usage on a machine with lower-end graphics card. As far as I know our code is not performing any significant amount of work. (we do have timers that goes off occasionally, say once per minute, but it shouldn’t use CPU constantly.)

I tried profiling the app, but it didn’t really help as most exclusive times are very small. I noticed an interesting thing though: I see 30+ calls per second to System.Windows.Media.MediaContext.AnimatedRenderMessageHandle as well as System.Windows.Media.Visual.MarkVisibleRealizations. Both calls seem to occur on the main UI thread.

My questions are:

– Are those calls supposed to occur while we’re hidden, or did I do something wrong to cause such behavior? (for one thing the word “Animated” concerns me.)

– How expensive are those calls?


From → WPF

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: