title: Silverlight/XNA animation lagging
body: <p>When I use XNA Framework (For windows Phone) my game work perfectly, but when I migrate on Silverlight/XNA Framework I got a problem with animation lagging.
  The problem is the following:
  When I set fixed time step to GameTimer (timer.UpdateInterval = TimeSpan.FromTicks(333333)), the REAL time step doesn't FIXED and timer events (OnUpdate, OnDraw) fires with different intervals.
  This code shows my problem more clearly: </p>
  
  <p>Silverlight/XNA Framework: (Animation lagging):</p>
  
  <pre><code>TimeSpan curNow;
  TimeSpan lastUpdate;
  TimeSpan lastDraw;
  
  public GamePage()
  {
      timer = new GameTimer();
      timer.UpdateInterval = TimeSpan.FromTicks(333333);
      timer.Update += OnUpdate;
      timer.Draw += OnDraw;
  }
  
  private void OnUpdate(object sender, GameTimerEventArgs e)
  {    
      curNow = new TimeSpan(DateTime.Now.Ticks);
      TimeSpan elapsed=e.ElapsedTime;//Always constant and has value: 33ms
      TimeSpan realElapsed =  curNow  -  lastUpdate;//Real elapsed time always changing and has a value between: 17-39ms (sometimes more then 39ms)
      lastUpdate =  curNow;
  }
  
  private void OnDraw(object sender, GameTimerEventArgs e)
  {
      curNow = new TimeSpan(DateTime.Now.Ticks);
      TimeSpan elapsed=e.ElapsedTime;//Always changing and has a value between: 17-39ms (sometimes more then 39ms)
      TimeSpan realElapsed =  curNow  -lastDraw;//Always changing and has a value between: 17-39ms (sometimes more then 39ms)
      lastDraw=  curNow;
  }
  </code></pre>
  
  <p>XNA Framework: (All works fine):</p>
  
  <pre><code>TimeSpan curNow;
  TimeSpan lastUpdate;
  TimeSpan lastDraw;
  
  public Game()
  {
      // Frame rate is 30 fps by default for Windows Phone.
      TargetElapsedTime = TimeSpan.FromTicks(333333);
  }
  
  protected override void Update(GameTime gameTime)
  {    
      curNow = new TimeSpan(DateTime.Now.Ticks);
      TimeSpan elapsed=gameTime.ElapsedGameTime;//Always constant and has value: 33ms
      TimeSpan realElapsed =  curNow - lastUpdate;//Real elapsed time has a value between: 34-35ms (sometimes more then 35ms)
      lastUpdate = curNow;
  }
  
  protected override void Draw(GameTime gameTime)
  {    
      curNow = new TimeSpan(DateTime.Now.Ticks);
      TimeSpan elapsed=gameTime.ElapsedGameTime ;//Value between: 33-34ms (sometimes more then 34ms)
      TimeSpan realElapsed = curNow - lastDraw;//Value between: 34-35ms (sometimes more then 35ms)
      lastDraw = curNow;
  }
  </code></pre>