private static IWingmanService GetService() { if (!WingmanIsRunning()) { //TODO just warn the user that they could see duplicat e try { //var wingmanPath = Path.GetFullPath(CLIENT_NAME); //var tempFile = Environment.ExpandEnvironmentVariables("%TEMP%\\LaunchWingman.bat"); //var command = $"start start start start start start start start start start start start {wingmanPath}"; //File.WriteAllText(tempFile, command); //Process.Start(tempFile); //using (Process wingmanProcess = new Process()) //{ // wingmanProcess.StartInfo.FileName = CLIENT_NAME; // wingmanProcess.StartInfo.UseShellExecute = true; // wingmanProcess.StartInfo.CreateNoWindow = true; // wingmanProcess.Start(); //} Process.Start(CLIENT_NAME); _wingmanService = null; System.Threading.Thread.Sleep(50); if (!WingmanIsRunning()) { System.Threading.Thread.Sleep(200); } //This is lazy, but should never happen since I've added KickoffWingmanProcess to startup //I've found that trying to connect to the service immediately after startup causes it to get into a fouled state where it will never work. System.Threading.Thread.Sleep(3000); } catch (Exception ex) { Utils.Logging.Logger.Error($"Exception in spawning the {CLIENT_PROCESS} process:", ex); } } if (_wingmanService == null) { try { _wingmanService = new WingmanServiceClient(); } catch (Exception ex) { Utils.Logging.Logger.Error($"Exception in connecting to the {CLIENT_PROCESS} client:", ex); } } return(_wingmanService); }
private static IWingmanService GetService() { if (!WingmanIsRunning()) { //TODO just warn the user that they could see duplicat e try { //var wingmanPath = Path.GetFullPath(CLIENT_NAME); //var tempFile = Environment.ExpandEnvironmentVariables("%TEMP%\\LaunchWingman.bat"); //var command = $"start start start start start start start start start start start start {wingmanPath}"; //File.WriteAllText(tempFile, command); //Process.Start(tempFile); //using (Process wingmanProcess = new Process()) //{ // wingmanProcess.StartInfo.FileName = CLIENT_NAME; // wingmanProcess.StartInfo.UseShellExecute = true; // wingmanProcess.StartInfo.CreateNoWindow = true; // wingmanProcess.Start(); //} Process.Start(CLIENT_NAME); _wingmanService = null; System.Threading.Thread.Sleep(50); if (!WingmanIsRunning()) { System.Threading.Thread.Sleep(200); } } catch (Exception ex) { Utils.Logging.Logger.Error("Exception in spawning the Wingman process:", ex); } } if (_wingmanService == null) { try { _wingmanService = new WingmanServiceClient(); } catch (Exception ex) { Utils.Logging.Logger.Error("Exception in connecting to the Wingman client:", ex); } } return(_wingmanService); }