Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

  • sl.ayer

    sl.ayer

    Participant

    1693 Points

    288 Posts

    Re: Any reason to use DispatcherTimer over Storyboard?

    Mar 10, 2009 06:45 AM | LINK

    In my experience DispetcherTimer is not very accurate. If you need precision of better the 50ms then it is probably not a good idea to use it. DispetcherTimer should be used if you need for your callback to execute in UI thread.

    Not sure about memory use, but I can't see it as a major concern with any timer implementation.

    Upd: I have to make a correction to the above statement. The accuracy issue with DispetcherTimer is not due to the timer itself, but rather to the fact that its callback is executed in UI thread. UI thread is throttled accordingly with application MaxFrameRate setting and that introduces error of ~1/(MaxFrameRate*2). For example if MaxFrameRate set to 60 then on average callback will be late for 8ms. The smaller your timer interval is the bigger error is going to be. All of the above applies to storyboard's Completed event since it executes in UI thread as well.