Compare commits

..

4 Commits

Author SHA1 Message Date
0ad2e86400 메인 루프 구조 2025-12-07 04:38:58 +09:00
3261e85b33 간단한 루프 추가 2025-12-07 04:30:11 +09:00
ed36f4e747 싱글톤 클래스 추가 2025-12-07 04:14:03 +09:00
5e673375d4 예외 발생시 에러코드 출력 가능하도록 수정 2025-12-07 04:13:40 +09:00
2 changed files with 96 additions and 1 deletions

View File

@@ -1,9 +1,11 @@
using System.Diagnostics;
namespace WarhoundConsole
{
public class Program
{
public static void Main(string[] args)
public static int Main(string[] args)
{
try
{
@@ -12,10 +14,46 @@ namespace WarhoundConsole
catch (Exception e)
{
Console.WriteLine(e);
return -1;
}
return 0;
}
private static void MainInternal(string[] args)
{
Singleton.I.Initialize(new());
var sw = Stopwatch.StartNew();
while (!Singleton.I.ExitRequested)
{
try
{
sw.Restart();
MainLoop();
sw.Stop();
const int targetFrameTimeMs = 10;
if (sw.Elapsed.Milliseconds < targetFrameTimeMs)
{
Thread.Sleep(targetFrameTimeMs - sw.Elapsed.Milliseconds);
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
Shutdown();
}
private static void MainLoop()
{
}
private static void Shutdown()
{
}

View File

@@ -0,0 +1,57 @@
namespace WarhoundConsole
{
public sealed class Singleton
{
public sealed class InitializeParams
{
// FILL SOMETHING
}
public static Singleton I => i ??= new();
private static Singleton? i = null;
private bool isInitialized;
public bool ExitRequested { get; private set; }
private Singleton()
{
this.isInitialized = false;
this.ExitRequested = false;
}
public bool Initialize(InitializeParams initializeParams)
{
try
{
if (this.isInitialized)
{
throw new InvalidOperationException("이미 초기화된 싱글톤");
}
if (initializeParams == null)
{
throw new ArgumentNullException(nameof(initializeParams));
}
this.InitializeInternal(initializeParams);
}
finally
{
this.isInitialized = true;
}
return true;
}
private void InitializeInternal(InitializeParams initializeParams)
{
// DO SOMETHING
}
public void Exit()
{
this.ExitRequested = true;
}
}
}