For my main game loop, what should I consider: DispatcherTimer Vs StoryBoard

I am writing a game in which I want to start an event for the main game loop, the event should be fired after a very short period of time.

DispatcherTimer helped me in implementing this, I came across this article

http://blogs.silverlight.net/blogs/msnow/archive/2008/07/09/storyboard-versus-dispatchertimer-for-animation-and-game-loops.aspx

according to this StoryBoard approach is better than dispatcher. This blog is for silverlight, I'm still looking in the MSDN docs if the WPF storyboard is also run on the second thread. Does anyone know if using a storyboard timer in WPF has any advantages over a dispatcher timer.

+2


source to share


2 answers


I would say that since its release from the official blog, it is probably correct, and the benefits are listed in this blog. This position was written by a senior SDET leader on the Web Tools team at Microsoft. So I would have to assume that what he says has merit.

From my research, the reasons why StoryboardTimer is better than DispatcherTimer looks like this:



  • The StoryBoard is processed on a separate thread that is not affected by the UI thread that is enabled by the DispatcherTimer.
  • The DispatcherTimer is a timer with a lower resolution than the timer behind the storyboard class, resulting in a loss of precision.
  • Storyboarding is more stable across different supported OS and web browsers.
+2


source


You can also try using the CompositionTarget.Rendering event, just stay away from the StoryBoard. Here are some links about CompositionTarget.Rendering:

How to render on one frame of an interval using CompositionTarget



Silverlight CompositionTarget.Rendering Game Loop

Fun With Animation Part 1 - Composition Target.Rendering

+4


source







All Articles