diff --git a/WarhoundConsole/Program.cs b/WarhoundConsole/Program.cs index 11d9691..8acf212 100644 --- a/WarhoundConsole/Program.cs +++ b/WarhoundConsole/Program.cs @@ -20,7 +20,17 @@ namespace WarhoundConsole 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 } } } diff --git a/WarhoundConsole/Singleton.cs b/WarhoundConsole/Singleton.cs index 6507889..97daf71 100644 --- a/WarhoundConsole/Singleton.cs +++ b/WarhoundConsole/Singleton.cs @@ -2,17 +2,56 @@ { 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 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; } } }