Compare commits
4 Commits
8458995132
...
0ad2e86400
| Author | SHA1 | Date | |
|---|---|---|---|
| 0ad2e86400 | |||
| 3261e85b33 | |||
| ed36f4e747 | |||
| 5e673375d4 |
@@ -1,9 +1,11 @@
|
|||||||
|
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace WarhoundConsole
|
namespace WarhoundConsole
|
||||||
{
|
{
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
public static int Main(string[] args)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -12,10 +14,46 @@ namespace WarhoundConsole
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Console.WriteLine(e);
|
Console.WriteLine(e);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void MainInternal(string[] args)
|
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()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
57
WarhoundConsole/Singleton.cs
Normal file
57
WarhoundConsole/Singleton.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user