public void Render(SharpDX.Direct2D1.DeviceContext deviceContext2D) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); deviceContext2D.BeginDraw(); deviceContext2D.Clear(SharpDX.Color.Black); deviceContext2D.AntialiasMode = SharpDX.Direct2D1.AntialiasMode.PerPrimitive; foreach (EntityViewModel entity in AllViewalbleEntities) { entity.Render(deviceContext2D); } foreach (var region in AllRegions) { region.Render(deviceContext2D); } deviceContext2D.EndDraw(); stopwatch.Stop(); fpsHistory.Dequeue(); fpsHistory.Enqueue(1000.0f / (float)(stopwatch.ElapsedMilliseconds)); //temp hack Task.Delay(50).Wait(); tickTimeHistory.Dequeue(); tickTimeHistory.Enqueue(GameManager.MillisecondsForLastTick); FPS = fpsHistory.Average(); TickTime = tickTimeHistory.Average(); }