diff --git a/GSS2.Test/PropgramUi.cs b/GSS2.Test/PropgramUi.cs index 4f69eea..f13dbfa 100644 --- a/GSS2.Test/PropgramUi.cs +++ b/GSS2.Test/PropgramUi.cs @@ -33,12 +33,30 @@ public partial class Program #if DEBUG if (debug && !System.Diagnostics.Debugger.IsAttached) { - Console.WriteLine("Waiting debugger attach"); - Console.WriteLine($"ProcessId: {Environment.ProcessPath} [{Environment.ProcessId}]"); - Console.WriteLine($"Thread: {Thread.CurrentThread.Name} [{Thread.CurrentThread.ManagedThreadId}]"); - while (!System.Diagnostics.Debugger.IsAttached) + bool keepWaiting = true; + + void CancelHandle(object? sender, ConsoleCancelEventArgs e) + { + e.Cancel = true; + keepWaiting = false; + Console.WriteLine("\nWait cancelled by user."); + Environment.Exit(0); + } + Console.CancelKeyPress += CancelHandle; + + Console.WriteLine("Waiting debugger attach (Press Ctrl+C to cancel)"); + Console.WriteLine($"Process Id: {Environment.ProcessId}"); + Console.WriteLine($"Process Name: {Environment.ProcessPath}"); + Console.WriteLine($"Thread Id: {Thread.CurrentThread.ManagedThreadId}"); + Console.WriteLine($"Thread Name: {Thread.CurrentThread.Name}"); + + while (!System.Diagnostics.Debugger.IsAttached && keepWaiting) Thread.Sleep(100); - System.Diagnostics.Debugger.Break(); + + if (System.Diagnostics.Debugger.IsAttached) + System.Diagnostics.Debugger.Break(); + + Console.CancelKeyPress -= CancelHandle; } #endif