30 lines
840 B
C#
30 lines
840 B
C#
using System.Diagnostics;
|
|
|
|
namespace Updater.Core;
|
|
|
|
public sealed class ProcessManager : IProcessManager
|
|
{
|
|
private readonly ILogger _log;
|
|
public ProcessManager(ILogger log) => _log = log;
|
|
|
|
public void StartApp(string installPath, string appExe, int delayMs)
|
|
{
|
|
var appPath = Path.Combine(installPath, appExe);
|
|
if (!File.Exists(appPath))
|
|
throw new FileNotFoundException("Executable not found after install", appPath);
|
|
|
|
if (delayMs > 0)
|
|
{
|
|
_log.Info($"Waiting {delayMs} ms before restart...");
|
|
Thread.Sleep(delayMs);
|
|
}
|
|
|
|
_log.Info($"Starting '{appExe}'...");
|
|
Process.Start(new ProcessStartInfo
|
|
{
|
|
FileName = appPath,
|
|
UseShellExecute = true,
|
|
WorkingDirectory = installPath
|
|
});
|
|
}
|
|
} |