Добавьте файлы проекта.
This commit is contained in:
30
Updater/Core/ProcessManager.cs
Normal file
30
Updater/Core/ProcessManager.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
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
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user