메인 루프 구조
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
|
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace WarhoundConsole
|
namespace WarhoundConsole
|
||||||
{
|
{
|
||||||
public class Program
|
public class Program
|
||||||
@@ -22,15 +24,38 @@ namespace WarhoundConsole
|
|||||||
{
|
{
|
||||||
Singleton.I.Initialize(new());
|
Singleton.I.Initialize(new());
|
||||||
|
|
||||||
bool exitRequested = Singleton.I.ExitRequested;
|
var sw = Stopwatch.StartNew();
|
||||||
while (!exitRequested)
|
while (!Singleton.I.ExitRequested)
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
sw.Restart();
|
||||||
|
MainLoop();
|
||||||
|
sw.Stop();
|
||||||
|
|
||||||
|
const int targetFrameTimeMs = 10;
|
||||||
exitRequested = Singleton.I.ExitRequested;
|
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()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user