Programming with .NET - Generalhttp://forums.silverlight.net//17.aspx/1?Programming+with+NET+GeneralGeneral discussions around authoring Silverlight .NET applications.Mon, 01 Jan 0001 00:00:00 -050017185472http://forums.silverlight.net//p/78615/185472.aspx/1?Any+reason+to+use+DispatcherTimer+over+Storyboard+Any reason to use DispatcherTimer over Storyboard? <p>I've seen various threads and blogs comparing DispatcherTimer with empty Storyboards. The consensus seems to be that a game loop should be implemented as a Storyboard, since it doesn't execute on the UI thread and utilizes a higher resolution timer. Sounds good to me.</p> <p>So the question comes to mind, why would I ever use a DispatcherTimer? If I have a dozen or so other&nbsp;timers (not related to the game loop) that aren't critical and can afford to miss their intervals by a bit, am I better off implementing those as DispatcherTimers? Will they use less memory? Do I risk hiccups in the UI if I'm running a bunch of them at once?</p> <p>Thanks in advance for the enlightenment!</p> 2009-03-10T03:37:52-04:00185546http://forums.silverlight.net//p/78615/185546.aspx/1?Re+Any+reason+to+use+DispatcherTimer+over+Storyboard+Re: Any reason to use DispatcherTimer over Storyboard? <p>In&nbsp;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.</p> <p>Not sure about memory use, but I can't see it as a major concern with any timer implementation.</p> <p>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&nbsp;<font size="2">MaxFrameRate setting and that introduces error of ~1/(<font size="2">MaxFrameRate*2). For example if <font size="2">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.&nbsp;All of the above applies to storyboard's Completed event since it executes in UI thread as well.</font></font></font></p> 2009-03-10T06:45:30-04:00242228http://forums.silverlight.net//p/78615/242228.aspx/1?Re+Re+Any+reason+to+use+DispatcherTimer+over+Storyboard+Re: Re: Any reason to use DispatcherTimer over Storyboard? <p>I still have some confusions:</p> <p>1. How can I be sure that <span><span class="selflink">MaxFrameRate value will always be 60 for every computer (including portable computers and so forth)? If 60 fps isn't supported on any machine with Silverlight then my game-loop&nbsp;</span></span><span><span class="selflink"></span></span>will make unexpected speed and it won't be good at all.<br> </p> <p>2. Is there any way to get more frequent (than 60/sec), stable, and platform-independent tick ? </p> <p>I tried to increase <span><span class="selflink">MaxFrameRate value but I didn't reached more than 450/sec and again I'm not sure that on another computer it won't give another result.<br> </span></span></p> 2009-07-03T20:14:15-04:00