diff --git a/WarhoundConsole/Program.cs b/WarhoundConsole/Program.cs index 8acf212..4c29d8c 100644 --- a/WarhoundConsole/Program.cs +++ b/WarhoundConsole/Program.cs @@ -1,4 +1,6 @@  +using System.Diagnostics; + namespace WarhoundConsole { public class Program @@ -22,15 +24,38 @@ namespace WarhoundConsole { Singleton.I.Initialize(new()); - bool exitRequested = Singleton.I.ExitRequested; - while (!exitRequested) + var sw = Stopwatch.StartNew(); + while (!Singleton.I.ExitRequested) { + try + { + sw.Restart(); + MainLoop(); + sw.Stop(); - - exitRequested = Singleton.I.ExitRequested; + const int targetFrameTimeMs = 10; + if (sw.Elapsed.Milliseconds < targetFrameTimeMs) + { + Thread.Sleep(targetFrameTimeMs - sw.Elapsed.Milliseconds); + } + } + catch (Exception e) + { + Console.WriteLine(e); + } } - // Graceful shutdown + Shutdown(); + } + + private static void MainLoop() + { + + } + + private static void Shutdown() + { + } } }