private Process StartPServeWithRTerm() { try { //--vanilla Combine // --no-save, --no-restore, --no-site-file, // --no-init-file --no-environ // TODO: maybe complete clear enviroment rm(list=ls()) // after Rserve Connect var arguments = new StringBuilder(); arguments.Append(Parameter.RProcessCommandLineArgs); // arguments.Append($"--vanilla -e \"library(Rserve); "); // arguments.Append($"Rserve(port = {Parameter.Port}, wait = TRUE);\""); ProcessLog.Clear(); var rtermProcess = new Process(); rtermProcess.StartInfo.FileName = Parameter.RTermPath; rtermProcess.StartInfo.Arguments = arguments.ToString(); rtermProcess.StartInfo.RedirectStandardOutput = true; rtermProcess.OutputDataReceived += RtermProcess_OutputDataReceived; rtermProcess.StartInfo.UseShellExecute = false; rtermProcess.StartInfo.CreateNoWindow = true; rtermProcess.Start(); rtermProcess.BeginOutputReadLine(); rtermProcess.WaitForExit(3000); logger.Debug($"rProcess started, Output: {ProcessLog.ToString()}"); return(rtermProcess); } catch (Exception ex) { logger.Error($"Error when starting R process: {ex.Message}"); return(null); } }