namespace RelayShared.Services; public static class ConsoleCommandService { public static CancellationTokenSource ShutdownTokenSource { get; } = new(); public static void Start() { Task.Run(() => { while (!ShutdownTokenSource.IsCancellationRequested) { var input = Console.ReadLine(); if (string.IsNullOrWhiteSpace(input)) continue; HandleCommand(input.Trim().ToLower()); } }); } private static void HandleCommand(string command) { switch (command) { case "exit": case "stop": Console.WriteLine("Shutting down..."); ShutdownTokenSource.Cancel(); break; default: Console.WriteLine($"Unknown command: {command}"); break; } } }