Answers for "show fps on c# winforms"

C#
0

show fps on c# winforms

DateTime _lastCheckTime = DateTime.Now;
long _frameCount = 0;

// called whenever a map is updated
void OnMapUpdated()
{
    Interlocked.Increment(ref _frameCount);
}

// called every once in a while
double GetFps()
{
    double secondsElapsed = (DateTime.Now - _lastCheckTime).TotalSeconds;
    long count = Interlocked.Exchange(ref _frameCount, 0);
    double fps = count / secondsElapsed;
    _lastCheckTime = DateTime.Now;
    return fps;
}
Posted by: Guest on September-06-2021

C# Answers by Framework

Browse Popular Code Answers by Language