WPF SDK Release Notes: Clean Your Clocks
Release notes for pre-release version of .NET 3.0 could be read with the hopes that some of the issues raised might be fixed before shipping. However, the final release notes are worth reading, as these are known issues that were not fixed. The release notes ship with the SDK and there is some WPF issues worth calling out. I personally have been bit by the animation leaks when using Handoff.Compose. Be sure to clean your clocks!
5.1.9 Pausing and Resuming an Animation Does Not Work as Expected when DesiredFrameRate
is Set
Timeline
objects with a DesiredFrameRate
value other than a null reference (Nothing in Visual Basic) do not pause and resume as expected.
5.1.10 An InvalidCastException
occurs when clicking on a ListBoxItem/ComboBoxItem/TabItem after animating SelectedIndex
Clicking on a ListBoxItem, ComboBoxItem, or TabItem after animating the SelectedIndex
property of its ListBox, ComboBox, or TabControl container throws an InvalidOperationException
.
5.1.11 Performance Impacts of HandoffBehavior.Compose
When you apply an animation to a property using the Compose HandoffBehavior, any clocks objects previously associated with that property continue to consume system resources; the timing system will not remove these clocks automatically.
To avoid performance issues when you apply a large number of clocks using HandofffBehavior.Compose
, you should remove composing clocks from the animated property after they complete. There are several ways to remove a clock.
- To remove all clocks from a property, use the
ApplyAnimationClock
orBeginAnimation
method of the animation object. Specify the property being animated as the first parameter, and a null reference (Nothing in Visual Basic) as the second. This will remove all animation clocks from the property. - To remove a specific
AnimationClock
from a list of clocks, use theController
property of theAnimationClock
to retrieve aClockController
, then call theClockController.Remove()
method of theClockController
. This is typically done in theCompleted
event handler for a clock. Note that only root clocks can be controlled by aClockController
; theController
property of a childClock
will return a null reference (Nothing in Visual Basic). Note also that theCompleted
event will not be called if the effective duration of the clock is forever. In that case, the user will need to determine when to callClockController.Remove()
.
This is primarily an issue for animations on objects that have a long lifetime. When an object is garbage collected, its clocks will also be disconnected and garbage collected.