using CliWrap; namespace RAIDAlert; public class Watchdog : BackgroundService { private const string HpCliUtil = "hpssacli.exe"; private const string PcBeeperUtil = "pc-beeper.exe"; private readonly ILogger _logger; public Watchdog(ILogger logger) { _logger = logger; } protected override async Task ExecuteAsync(CancellationToken stoppingToken) { string hpSsaCli = Path.Combine(Environment.ProcessPath!, HpCliUtil); string pcBeeper = Path.Combine(Environment.ProcessPath!, PcBeeperUtil); while (!stoppingToken.IsCancellationRequested) { var result = await Cli.Wrap("path/to/exe") .WithArguments(new[] {"--foo", "bar"}) .WithWorkingDirectory("work/dir/path") .ExecuteAsync(); await Task.Delay(1000, stoppingToken); } } }