private void WaitForServiceStart() { string heartBeatOK = commandClient.SendMessageWithRetries(Command.Alive, retries: 5); if (heartBeatOK == StatusCode.Timeout) { string error = "Backend not responding. Check if AutoDarkModeSvc.exe is running and try again"; MsgBox msgErr = new(error, AutoDarkModeApp.Properties.Resources.errorOcurredTitle, "error", "close") { }; msgErr.ShowDialog(); return; } }
private static void Relaunch(bool restoreShell, bool restoreApp, bool failed) { try { using Process svc = new(); svc.StartInfo.UseShellExecute = false; svc.StartInfo.FileName = Path.Combine(Extensions.ExecutionPathSvc); _ = svc.Start(); if (restoreApp) { using Process app = new(); app.StartInfo.UseShellExecute = false; app.StartInfo.FileName = Path.Combine(Extensions.ExecutionPathApp); _ = app.Start(); } if (restoreShell) { using Process shell = new(); shell.StartInfo.UseShellExecute = false; shell.StartInfo.FileName = Path.Combine(Extensions.ExecutionPathShell); _ = shell.Start(); } if (failed) { if (client.SendMessageWithRetries(Command.UpdateFailed, retries: 5) == StatusCode.Timeout) { Logger.Warn("could not send failed upate message due to service not starting in time"); } } } catch (Exception ex) { Logger.Error(ex, "error while restarting auto dark mode"); } }