packages/Windows API Code Pack 1.1/source/Samples/DirectX/CS/Direct2D/D2DShapes/D2DShapesControl.cs
/// <summary>
/// Calculates Frames Per Second if at least a second passed since previous update.
/// Should be called whenever a frame is drawn on the control
/// </summary>
Calculates Frames Per Second if at least a second passed since previous update.
Should be called whenever a frame is drawn on the control
Calculates Frames Per Second if at least a second passed since previous update . Should be called whenever a frame is drawn on the control
private void CalculateFPS()
        {
            int currentTickCount = Environment.TickCount;
            int ticks = currentTickCount - lastTickCount;
            if (ticks >= 1000)
            {
                Fps = (float)frameCount * 1000 / ticks;
                frameCount = 0;
                lastTickCount = currentTickCount;
                BeginInvoke(new MethodInvoker(delegate
                                                  {
                                                      if (fpsChanged != null)
                                                          fpsChanged(this, EventArgs.Empty);
                                                  }));
            }
            frameCount++;
        }
private void CalculateFPS ( ) { int currentTickCount = Environment . TickCount ; int ticks = currentTickCount - lastTickCount ; if ( ticks >= 1000 ) { Fps = ( float ) frameCount * 1000 / ticks ; frameCount = 0 ; lastTickCount = currentTickCount ; BeginInvoke ( new MethodInvoker ( delegate { if ( fpsChanged != null ) fpsChanged ( this , EventArgs . Empty ) ; } ) ) ; } frameCount ++ ; }
Calculates Frames Per Second if at least a second passed since previous update.
Calculates Frames Per Second if at least a second passed since previous update .