mirror of
https://github.com/Stone-Red-Code/RemSox.git
synced 2026-09-07 23:41:47 +02:00
Add command interruption support with Ctrl+C and cancellation tokens
This commit is contained in:
@@ -18,11 +18,6 @@ public class StartGuiCommand : ICommand
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
foreach (Process process in ProcessManager.GetProcessesOfType<CliProcess>())
|
||||
{
|
||||
ProcessManager.StopProcess(process.Id);
|
||||
}
|
||||
|
||||
_ = ProcessManager.SpawnProcess<DesktopProcess>();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,5 @@ public class StopGuiCommand : ICommand
|
||||
{
|
||||
await ProcessManager.StopProcessAndWaitAsync(process.Id);
|
||||
}
|
||||
|
||||
_ = ProcessManager.SpawnProcess<CliProcess>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,18 @@ namespace RemSox.UI.CLI.Commands
|
||||
|
||||
public string Description => "Start the YesNt interpreter";
|
||||
|
||||
private int processId;
|
||||
|
||||
public async Task ExecuteAsync(string? arguments, Action<string> printLine)
|
||||
{
|
||||
int processId = ProcessManager.SpawnProcess<Processes.YesNtInterpreterProcess>(arguments?.Split(',') ?? []);
|
||||
processId = ProcessManager.SpawnProcess<Processes.YesNtInterpreterProcess>(arguments?.Split(',') ?? []);
|
||||
await ProcessManager.WaitForProcessExitAsync(processId);
|
||||
}
|
||||
|
||||
public Task StopAsync()
|
||||
{
|
||||
ProcessManager.StopProcess(processId);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user