간단한 루프 추가

This commit is contained in:
2025-12-07 04:30:11 +09:00
parent ed36f4e747
commit 3261e85b33
2 changed files with 52 additions and 3 deletions

View File

@@ -20,7 +20,17 @@ namespace WarhoundConsole
private static void MainInternal(string[] args) private static void MainInternal(string[] args)
{ {
Singleton.I.Initialize(); Singleton.I.Initialize(new());
bool exitRequested = Singleton.I.ExitRequested;
while (!exitRequested)
{
exitRequested = Singleton.I.ExitRequested;
}
// Graceful shutdown
} }
} }
} }

View File

@@ -2,17 +2,56 @@
{ {
public sealed class Singleton public sealed class Singleton
{ {
public sealed class InitializeParams
{
// FILL SOMETHING
}
public static Singleton I => i ??= new(); public static Singleton I => i ??= new();
private static Singleton? i = null; private static Singleton? i = null;
private bool isInitialized;
public bool ExitRequested { get; private set; }
private Singleton() private Singleton()
{ {
this.isInitialized = false;
this.ExitRequested = false;
} }
public void Initialize() 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;
} }
} }
} }