This project is read-only.

Reducing CPU consumption

Jun 16, 2008 at 2:54 PM
After reading the following post from Marlon Grech, I made a little hack on ElementFlow.cs to add a property so that one could tune the timeline framerate.  I played around with numerous framerates and between 15-20 was perfectly fine for what I was doing. 

http://marlongrech.wordpress.com/2008/06/13/wpf-reducing-cpu-consumption-for-animations/

Here's the quick and dirty hack -

 #region Properties

        public int FrameRate
        {
            get { return (int)GetValue(FrameRateProperty); }
            set { SetValue(FrameRateProperty, value); }
        }

 #endregion

 #region Dependency Properties

        public static readonly DependencyProperty FrameRateProperty =
            DependencyProperty.Register("FrameRate", typeof(int), typeof(ElementFlow),
            new PropertyMetadata(60, OnFrameRateChanged));

 #endregion

 #region DependencyProperty PropertyChange Callbacks

        private static void OnFrameRateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Timeline.DesiredFrameRateProperty.OverrideMetadata(
                typeof(Timeline),
                new FrameworkPropertyMetadata { DefaultValue = e.NewValue }
                );
        }

 #endregion

Jun 16, 2008 at 8:25 PM
Thanks Ricky...this should make it to the next update !