From 3261e85b33ff90b87c92828f4292419abce1bfaa Mon Sep 17 00:00:00 2001 From: tymmkang Date: Sun, 7 Dec 2025 04:30:11 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B0=84=EB=8B=A8=ED=95=9C=20=EB=A3=A8?= =?UTF-8?q?=ED=94=84=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarhoundConsole/Program.cs | 12 +++++++++- WarhoundConsole/Singleton.cs | 43 ++++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 3 deletions(-) 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; } } }