간단한 루프 추가
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user