메인 루프 구조
This commit is contained in:
@@ -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()
|
||||
{
|
||||
// DO SOMETHING
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user