public void Restart() { // Do not block UI when calling other process via named pipe Task.Run(() => { try { if (!IpcClient.GetRunningApps().Contains("ClientLauncher")) { string clPath = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "Tools", "MP2-ClientLauncher", "MP2-ClientLauncher.exe"); Process.Start(clPath); int waitCounter = 10; // Wait until process is running and the pipe was created. while (waitCounter-- > 0 && !IpcClient.GetRunningApps().Contains("ClientLauncher")) { Thread.Sleep(200); } } // Sends a command to tray launcher that we want to be restarted. using (var client = new IpcClient("ClientLauncher")) { client.Connect(); client.RequestRestart(); } } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Error("Error trying to send restart request.", ex); } }); }