protected bool StartRemoteApplication(string sdkCode) { string appId = _sessionConfiguration.AppId; DebugWriteToOutput($"Starting launch_app({appId}; SDK={sdkCode})"); ProcessProxy launchAppProcess = SDBLib.CreateSdbProcess(true, true); if (launchAppProcess == null) { WriteToOutput(SDBLib.FormatSdbRunResult(SDBLib.SdbRunResult.CreateProcessError)); return(false); } launchAppProcess.StartInfo.Arguments = GetSdbLaunchCommand(sdkCode); string firstOutputLine = null; _launchAppStartedEvent.Reset(); launchAppProcess.OutputDataReceived += ((sender, e) => { if (!String.IsNullOrEmpty(e.Data)) { firstOutputLine = e.Data; _launchAppStartedEvent.Set(); DebugWriteToOutput($"{appId} : {e.Data}"); } }); launchAppProcess.ErrorDataReceived += ((sender, e) => { if (!String.IsNullOrEmpty(e.Data)) { DebugWriteToOutput($"{appId} [StdErr] {e.Data}"); } }); launchAppProcess.Exited += (object sender, EventArgs e) => { DebugWriteToOutput($"launch_app({appId}) finished"); launchAppProcess.Dispose(); }; Debug.WriteLine("{0} {1} StartRemoteApplication command '{2}'", DateTime.Now, this.ToString(), launchAppProcess.StartInfo.Arguments); launchAppProcess.Start(); DebugWriteProcessToOutput(launchAppProcess); try { launchAppProcess.BeginOutputReadLine(); launchAppProcess.BeginErrorReadLine(); if (_launchAppStartedEvent.WaitOne(30000)) { if (firstOutputLine.EndsWith("launch failed")) { WriteToOutput($"launch_app({appId}) failed"); return(false); } } } catch (Exception ex) { Debug.WriteLine(ex.Message); } return(true); }