Files
Warhound/WarhoundConsole/Program.cs
2025-12-07 05:29:06 +09:00

67 lines
1.5 KiB
C#

using System.Diagnostics;
namespace WarhoundConsole
{
public class Program
{
public static int Main(string[] args)
{
try
{
MainInternal(args);
}
catch (Exception e)
{
Console.WriteLine(e);
return -1;
}
return 0;
}
private static void MainInternal(string[] args)
{
Singleton.I.Initialize(new());
var jobs = new List<Job>();
var sw = Stopwatch.StartNew();
while (!Singleton.I.ExitRequested)
{
try
{
sw.Restart();
foreach (var job in jobs)
{
_ = job.TryExecute();
}
sw.Stop();
const int targetFrameTimeMs = 10;
if (sw.Elapsed.Milliseconds < targetFrameTimeMs)
{
Thread.Sleep(targetFrameTimeMs - sw.Elapsed.Milliseconds);
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
foreach (var job in jobs)
{
job.Wait();
}
Shutdown();
}
private static void Shutdown()
{
// DO SOMETHING
}
}
}