protected override void OnUpdate(UpdateEventArgs updateArgs) { if (updateArgs.ElapsedTimeInS < 0.0001) { // This is basically to skip the first frame, because its // elapsed time is out of whack. We do a GC though, to clean up // initialization garbage, to prevent that from happening in // game This saves one big stutter a few seconds into the game. GC.Collect(); return; } var performanceSummary = new PerformanceSummary( _performanceMonitor.FrameTime.Stats, _performanceMonitor.ElapsedTime.Stats, _performanceMonitor.FrameTime.CurrentValue, _gameStatistics.NrGameObjects); var e = new BeardedUpdateEventArgs(updateArgs, performanceSummary); _performanceMonitor.StartFrame(e.UpdateEventArgs.ElapsedTimeInS); _inputManager.Update(Focused); if (_inputManager.IsKeyPressed(Key.AltLeft) && _inputManager.IsKeyPressed(Key.F4)) { Close(); } _screenManager.Update(e); _performanceMonitor.EndFrame(); _afterFrame?.Invoke(this, e); }