Silverlight MultiScaleImage control bug and CPU usage

673 Views Asked by At

How to use animation and MultiScaleImage control on the same UserControl?
What I have found that if you place a MultiScaleImage and animation on the same UserControl, you always get a high CPU usage. Is that a MultiScaleImage control bug? Here's a sample project. (just a grid, MultiScaleImageControl and a fading rectangle)

Why CPU usage is high? When animation is playing, UserControl fires LayoutUpdated event and MultiScaleImage catches that event and redraws itself. So if MaxFrameRate=60 (default value), then MultiScaleImage every second redraws itself ~60 times (MultiScaleImage.LayoutUpdated gets fired ~60 times) causing high CPU usage:

  • ~20% CPU, if MaxFrameRate=10
  • ~40% CPU, if MaxFrameRate=30
  • ~85% CPU, if MaxFrameRate=60 (default)

Shouldn't MultiScaleImage redraw itsef (or recalculate something CPU intensive) only on SizeChanged event? Otherwise why use this control if I can't use animation?

1

There are 1 best solutions below

0
On

It looks like now it's a known bug :)