feat: add DALAMUD_WAIT_DEBUGGER env var

This commit is contained in:
goaaats 2021-11-07 16:43:08 +01:00
parent c06a29a2d4
commit 93863dbc8a
No known key found for this signature in database
GPG key ID: F18F057873895461
2 changed files with 13 additions and 0 deletions

View file

@ -27,6 +27,11 @@ namespace Dalamud.Configuration.Internal
/// </summary>
public static bool DalamudForceMinHook { get; } = GetEnvironmentVariable("DALAMUD_FORCE_MINHOOK");
/// <summary>
/// Gets a value indicating whether or not Dalamud should wait for a debugger to be attached when initializing.
/// </summary>
public static bool DalamudWaitForDebugger { get; } = GetEnvironmentVariable("DALAMUD_WAIT_DEBUGGER");
private static bool GetEnvironmentVariable(string name)
=> bool.Parse(Environment.GetEnvironmentVariable(name) ?? "false");
}

View file

@ -52,6 +52,14 @@ namespace Dalamud
/// <param name="info">The <see cref="DalamudStartInfo"/> containing information needed to initialize Dalamud.</param>
private static void RunThread(DalamudStartInfo info)
{
if (EnvironmentConfiguration.DalamudWaitForDebugger)
{
while (!Debugger.IsAttached)
{
Thread.Sleep(100);
}
}
// Setup logger
var levelSwitch = InitLogging(info.WorkingDirectory);