forked from amkovkov/GranuSightSoftware2
feat: add ui exit on ctrl+c
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
using System.Reflection;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging.Console;
|
||||
|
||||
using Avalonia;
|
||||
using Avalonia.OpenGL.Egl;
|
||||
|
||||
using GSS2.Core;
|
||||
using GSS2.Core.Logging;
|
||||
using GSS2.Core.Analysis.AmineContent.Database;
|
||||
|
||||
using ConsoleFormatter = GSS2.Core.Logging.ConsoleFormatter;
|
||||
|
||||
namespace GSS2.Test;
|
||||
@@ -13,6 +17,7 @@ namespace GSS2.Test;
|
||||
public class Program
|
||||
{
|
||||
public static IHost ApplicationHost { get; } = BuildHostApp();
|
||||
public static event ConsoleCancelEventHandler? ShutdownRequested;
|
||||
|
||||
[STAThread]
|
||||
public static int Main(string[] args)
|
||||
@@ -33,9 +38,19 @@ public class Program
|
||||
Console.WriteLine($"\t--console - in DRM rendering mode do not suppress console output");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Console.CancelKeyPress += new ConsoleCancelEventHandler(OnProgramShutdown);
|
||||
Console.WriteLine("Press Ctrl+C to shut down.");
|
||||
|
||||
return builder.StartWithClassicDesktopLifetime(args);
|
||||
}
|
||||
|
||||
private static void OnProgramShutdown(object? sender, ConsoleCancelEventArgs ea)
|
||||
{
|
||||
ShutdownRequested?.Invoke(sender, ea);
|
||||
ea.Cancel = true;
|
||||
}
|
||||
|
||||
private static void SilenceConsole()
|
||||
{
|
||||
new Thread(() =>
|
||||
|
||||
Reference in New Issue
Block a user