本文整理汇总了C#中System.Diagnostics.Process.BeginErrorReadLine方法的典型用法代码示例。如果您正苦于以下问题:C# System.Diagnostics.Process.BeginErrorReadLine方法的具体用法?C# System.Diagnostics.Process.BeginErrorReadLine怎么用?C# System.Diagnostics.Process.BeginErrorReadLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Diagnostics.Process
的用法示例。
在下文中一共展示了System.Diagnostics.Process.BeginErrorReadLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckEpub
//CheckEpubを実施、Output/Errorを表示する
public void CheckEpub()
{
//EPUBチェック実施中パネルを表示する
var checkingDlg = new EpubCheckingDialog();
checkingDlg.Show();
var p = new System.Diagnostics.Process();
//実行ファイル
p.StartInfo.FileName = javaPath;
//引数
var args = "-jar "
+ "\""+ epubCheckPath + "\" "
+" \"" + epubPath + "\"";
p.StartInfo.Arguments = args;
//出力とエラーをストリームに書き込むようにする
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
//OutputDataReceivedとErrorDataReceivedイベントハンドラを追加
p.OutputDataReceived += OutputDataReceived;
p.ErrorDataReceived += ErrorDataReceived;
p.StartInfo.RedirectStandardInput = false;
p.StartInfo.CreateNoWindow = true;
p.Start();
p.BeginOutputReadLine();
p.BeginErrorReadLine();
p.WaitForExit();
p.Close();
var resultDlg = new EpubCheckResultDialog();
//Outputをコピーする
foreach (var output in outputLines)
{
resultDlg.outputTextBox.Text += (output + "\n");
}
//Errorをコピーする
if (errorLines.Count> 1)
{
foreach (var error in errorLines)
{
resultDlg.errorTextBox.Text += (error + "\n");
}
}
else
{
resultDlg.errorTextBox.Text = "エラーはありませんでした。";
}
checkingDlg.Close();
resultDlg.ShowDialog();
}
示例2: PDF2SWF
/// <summary>
/// PDF格式转为SWF
/// </summary>
/// <param name="pdfPath">PDF文件地址</param>
/// <param name="swfPath">生成后的SWF文件地址</param>
/// <param name="beginpage">转换开始页</param>
/// <param name="endpage">转换结束页</param>
private static bool PDF2SWF(string pdfPath, string swfPath, int beginpage, int endpage, int photoQuality)
{
string exe = HttpContext.Current.Server.MapPath("~/Bin/tools/pdf2swf-0.9.1.exe");
pdfPath = HttpContext.Current.Server.MapPath(pdfPath);
swfPath = HttpContext.Current.Server.MapPath(swfPath);
if (!System.IO.File.Exists(exe) || !System.IO.File.Exists(pdfPath) || System.IO.File.Exists(swfPath))
{
return false;
}
StringBuilder sb = new StringBuilder();
sb.Append(" \"" + pdfPath + "\"");
sb.Append(" -o \"" + swfPath + "\"");
sb.Append(" -s flashversion=9");
if (endpage > GetPageCount(pdfPath)) endpage = GetPageCount(pdfPath);
sb.Append(" -p " + "\"" + beginpage + "" + "-" + endpage + "\"");
sb.Append(" -j " + photoQuality);
string Command = sb.ToString();
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = exe;
p.StartInfo.Arguments = Command;
p.StartInfo.WorkingDirectory = HttpContext.Current.Server.MapPath("~/Bin/");
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = false;
p.Start();
p.BeginErrorReadLine();
p.WaitForExit();
p.Close();
p.Dispose();
return true;
}
示例3: FileCrypt
/// <summary>
/// 文件加解密
/// </summary>
/// <param name="oFileName">原文件地址</param>
/// <param name="EncodeOrDecode">加密或解密参数,如:-d、-f</param>
/// <param name="Password">密码</param>
/// <returns></returns>
public static bool FileCrypt(string oFileName, string EncodeOrDecode, string Password)
{
string jpfile = HttpContext.Current.Server.MapPath("~/Bin/tools/jpfile.exe");
if ((!System.IO.File.Exists(jpfile)) || (!System.IO.File.Exists(HttpContext.Current.Server.MapPath(oFileName))))
{
return false;
}
oFileName = HttpContext.Current.Server.MapPath(oFileName);
string Command = EncodeOrDecode + " \"" + oFileName + "\" \"" + Password + "\"";
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = jpfile;
p.StartInfo.Arguments = Command;
p.StartInfo.WorkingDirectory = HttpContext.Current.Server.MapPath("~/Bin/");
p.StartInfo.UseShellExecute = false;//不使用操作系统外壳程序 启动 线程
//p.StartInfo.RedirectStandardInput = true;
//p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;//把外部程序错误输出写到StandardError流中(这个一定要注意,jpfile的所有输出信息,都为错误输出流,用 StandardOutput是捕获不到任何消息的...
p.StartInfo.CreateNoWindow = false;//不创建进程窗口
p.Start();//启动线程
p.BeginErrorReadLine();//开始异步读取
p.WaitForExit();//等待完成
//p.StandardError.ReadToEnd();//开始同步读取
p.Close();//关闭进程
p.Dispose();//释放资源
return true;
}
示例4: ConvertFlv
/// <summary>
/// 视频格式转为Flv
/// </summary>
/// <param name="vFileName">原视频文件地址</param>
/// <param name="ExportName">生成后的Flv文件地址</param>
public bool ConvertFlv(string vFileName, string ExportName)
{
if ((!System.IO.File.Exists(ffmpegtool)) || (!System.IO.File.Exists(HttpContext.Current.Server.MapPath(vFileName))))
{
return false;
}
vFileName = HttpContext.Current.Server.MapPath(vFileName);
ExportName = HttpContext.Current.Server.MapPath(ExportName);
string Command = " -i \"" + vFileName + "\" -y -ab 32 -ar 22050 -b 800000 -s 480*360 \"" + ExportName + "\""; //Flv格式
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = ffmpegtool;
p.StartInfo.Arguments = Command;
p.StartInfo.WorkingDirectory = HttpContext.Current.Server.MapPath("~/tools/");
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = false;
p.Start();
p.BeginErrorReadLine();
p.WaitForExit();
p.Close();
p.Dispose();
return true;
}
示例5: Exec
public static string Exec(String command)
{
Console.WriteLine("command : " + command);
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = "/c " + command;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.Start();
var stdout = new StringBuilder();
var stderr = new StringBuilder();
p.OutputDataReceived += (sender, e) => {
if (e.Data != null) {
stdout.AppendLine(e.Data);
}
};
p.ErrorDataReceived += (sendar, e) => {
if (e.Data != null) {
stderr.AppendLine(e.Data);
}
};
p.BeginOutputReadLine();
p.BeginErrorReadLine();
var output = new StringBuilder();
var isTimeOut = false;
if (!p.WaitForExit(3000)) {
isTimeOut = true;
p.Kill();
}
p.CancelOutputRead();
p.CancelErrorRead();
output.Append(stdout.ToString());
output.Append(stderr.ToString());
if (isTimeOut) {
output.Append("TIMEOUT.");
}
return output.ToString();
}
示例6: Execute
public static string Execute(string executable, string workingdir, string arguments, params object[] vaargs)
{
using( System.Diagnostics.Process process = new System.Diagnostics.Process() )
{
process.StartInfo.UseShellExecute = false;
process.StartInfo.FileName = executable;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.WorkingDirectory = workingdir;
process.StartInfo.Arguments = string.Format(arguments, vaargs);
if(!process.Start())
{
throw new Error("{0}: Failed to start {1}.", executable, process.StartInfo.Arguments);
}
using( Handler stderr = new Handler(), stdout = new Handler() )
{
process.OutputDataReceived += stdout.OnOutput;
process.BeginOutputReadLine();
process.ErrorDataReceived += stderr.OnOutput;
process.BeginErrorReadLine();
process.WaitForExit();
if(0 != process.ExitCode)
{
throw new Error("Failed to execute {0} {1}, exit code was {2}", executable, process.StartInfo.Arguments, process.ExitCode);
}
stderr.sentinel.WaitOne();
stdout.sentinel.WaitOne();
return stdout.buffer + "\n" + stderr.buffer;
}
}
}
示例7: LaunchKindleGen
internal static int LaunchKindleGen(DirectoryInfo tempFolder)
{
FileInfo fileApp = new FileInfo(tempFolder + "/kindlegen.exe");
File.Copy("kindlegen.exe", fileApp.FullName);
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.RedirectStandardError = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.FileName = fileApp.FullName;
p.StartInfo.WorkingDirectory = fileApp.DirectoryName;
p.StartInfo.Arguments = "en2ki.opf";
p.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(p_ErrorDataReceived);
//p.EnableRaisingEvents = true;
p.Start();
p.BeginErrorReadLine();
p.WaitForExit();
return p.ExitCode;
}
示例8: PDF2Swf
/// <summary>
/// PDF格式转为SWF
/// </summary>
/// <param name="pdfPath">原视频文件地址,如/a/b/c.pdf</param>
/// <param name="swfPath">生成后的FLV文件地址,如/a/b/c.swf</param>
/// <param name="beginpage">转换开始页</param>
/// <param name="endpage">转换结束页</param>
/// <param name="photoQuality"></param>
/// <returns></returns>
public static bool PDF2Swf(string pdfPath, string swfPath, int beginpage, int endpage, int photoQuality)
{
const string tooldir = "~/Utils/PDFtoSWF/";//PDFtoSWF工具目录地址
string exe = HttpContext.Current.Server.MapPath(tooldir + "pdf2swf.exe");
pdfPath = HttpContext.Current.Server.MapPath(pdfPath);
swfPath = HttpContext.Current.Server.MapPath(swfPath);
if (!System.IO.File.Exists(exe) || !System.IO.File.Exists(pdfPath))
{
return false;
}
if (System.IO.File.Exists(swfPath))
System.IO.File.Delete(swfPath);
StringBuilder sb = new StringBuilder();
sb.Append(" \"" + pdfPath + "\"");//input
sb.Append(" -o \"" + swfPath + "\"");//output
//sb.Append(" -z");
sb.Append(" -s flashversion=9");//flash version
//sb.Append(" -s disablelinks");//禁止PDF里面的链接
if (endpage > GetPageCount(pdfPath)) endpage = GetPageCount(pdfPath);
sb.Append(" -p " + "\"" + beginpage + "" + "-" + endpage + "\"");//page range
sb.Append(" -j " + photoQuality);//SWF中的图片质量
string Command = sb.ToString();
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = exe;
p.StartInfo.Arguments = Command;
p.StartInfo.WorkingDirectory = HttpContext.Current.Server.MapPath(tooldir);
p.StartInfo.UseShellExecute = false;//不使用操作系统外壳程序 启动 线程
//p.StartInfo.RedirectStandardInput = true;
//p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;//把外部程序错误输出写到StandardError流中(这个一定要注意,pdf2swf-0.9.1.exe的所有输出信息,都为错误输出流,用 StandardOutput是捕获不到任何消息的...
p.StartInfo.CreateNoWindow = true;//不创建进程窗口
p.Start();//启动线程
p.BeginErrorReadLine();//开始异步读取
p.WaitForExit();//等待完成
//p.StandardError.ReadToEnd();//开始同步读取
p.Close();//关闭进程
p.Dispose();//释放资源
if (!System.IO.File.Exists(swfPath))
return false;
else
return true;
}
示例9: deleteFiles
private void deleteFiles()
{
var psi = new System.Diagnostics.ProcessStartInfo(Path.Combine(_myDir.FullName, "delete_files.cmd"));
psi.EnvironmentVariables.Add("DATFILES_DIR", _dataDirectory);
psi.EnvironmentVariables.Add("INSTALL_DIR", _installDirectory);
psi.RedirectStandardError = true;
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false;
psi.CreateNoWindow = true;
psi.ErrorDialog = false;
var errorWH = new System.Threading.ManualResetEvent(false);
var outputWH = new System.Threading.ManualResetEvent(false);
using (System.Diagnostics.Process p = new System.Diagnostics.Process())
{
p.StartInfo = psi;
p.OutputDataReceived += (s, e) =>
{
if (e.Data == null)
{
outputWH.Set();
}
else
{
_logger.WriteLine(e.Data);
}
};
p.ErrorDataReceived += (s, e) =>
{
if (e.Data == null)
{
errorWH.Set();
}
else
{
_logger.WriteLine(e.Data);
}
};
p.Start();
p.BeginErrorReadLine();
p.BeginOutputReadLine();
p.WaitForExit();
errorWH.WaitOne();
outputWH.WaitOne();
if (p.ExitCode != 0)
{
throw new Exception("Batch file returned with exit code of " + p.ExitCode);
}
}
}
示例10: UnRegister
/// <summary>
/// Run the blackberry-signer tool with parameters passed in
/// </summary>
/// <returns></returns>
public bool UnRegister()
{
bool success = false;
try
{
System.Diagnostics.Process p = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = p.StartInfo;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardOutput = true;
p.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(ErrorDataReceived);
p.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(OutputDataReceived);
//run register tool
startInfo.FileName = "cmd.exe";
startInfo.WorkingDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + "\\BlackBerry\\VSPlugin-NDK\\qnxtools\\bin\\";
startInfo.Arguments = string.Format("/C blackberry-signer.bat -cskdelete");
p.Start();
p.BeginErrorReadLine();
p.BeginOutputReadLine();
p.WaitForExit();
if (p.ExitCode != 0)
{
success = false;
}
else
{
/// Remove Files
FileInfo fi_p12 = new FileInfo(System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Research In Motion\author.p12");
FileInfo fi_csk = new FileInfo(System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Research In Motion\bbidtoken.csk");
fi_p12.Delete();
fi_csk.Delete();
/// Set password to blank
setPassword("");
success = true;
}
p.Close();
}
catch (Exception e)
{
_errors += e.Message + "\n";
success = false;
}
return success;
}
示例11: Register
/// <summary>
/// Run the blackberry-signer tool with parameters passed in
/// </summary>
/// <returns></returns>
public bool Register(string authorID, string password)
{
bool success = false;
if (authorID.Trim().ToUpper().Contains("BLACKBERRY"))
{
_errors += "BlackBerry is a reserved word and cannot be used in \"author name\".\n";
return false;
}
System.Diagnostics.Process p = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = p.StartInfo;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardOutput = true;
p.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(ErrorDataReceived);
p.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(OutputDataReceived);
//run register tool
startInfo.FileName = "cmd.exe";
startInfo.WorkingDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + "\\BlackBerry\\VSPlugin-NDK\\qnxtools\\bin\\";
startInfo.Arguments = string.Format("/C blackberry-keytool -genkeypair -storepass {0} -author {1}", password, "\"" + authorID + "\"");
try
{
p.Start();
p.BeginErrorReadLine();
p.BeginOutputReadLine();
p.WaitForExit();
if (p.ExitCode != 0)
success = false;
else
success = true;
p.Close();
}
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine(startInfo.Arguments);
System.Diagnostics.Debug.WriteLine(e.Message);
success = false;
}
setPassword(password);
return success && string.IsNullOrEmpty(_errors);
}
示例12: Start
public bool Start()
{
// if hybris is still running we don't need to start again
if (this.IsAlive) return true;
this.Status = AzurePluginStatus.Starting;
this.StatusMessage = string.Empty;
try
{
// Prepare hybris start
string hybrisRoot = Path.Combine(BaseDirectory, "hybris");
string hybrisWorkingDirectory = Path.Combine(hybrisRoot, "bin", "platform");
string hybrisStartCommandFileName = Path.Combine(hybrisWorkingDirectory, "hybris-start.cmd");
// Start hybris process
_HybrisJavaProcess = new System.Diagnostics.Process
{
StartInfo = new System.Diagnostics.ProcessStartInfo
{
WorkingDirectory = hybrisWorkingDirectory,
FileName = hybrisStartCommandFileName,
Arguments = string.Empty,
UseShellExecute = false,
LoadUserProfile = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
RedirectStandardInput = true,
CreateNoWindow = true,
WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden,
},
EnableRaisingEvents = true,
};
_HybrisJavaProcess.OutputDataReceived += (s, a) => { if (!string.IsNullOrWhiteSpace(a.Data)) Trace.TraceVerbose("HybrisPlugin: Hybris process output: " + a.Data); };
_HybrisJavaProcess.ErrorDataReceived += (s, a) => { if (!string.IsNullOrWhiteSpace(a.Data)) Trace.TraceAndLogError("HybrisPlugin", "Hybris process error: " + a.Data); };
_HybrisJavaProcess.Exited += delegate(object sender, EventArgs e)
{
if (!this.ConfigStopHybris)
{
Trace.TraceAndLogError("HybrisPlugin", "Hybris process exited! ExitCode " + (sender as System.Diagnostics.Process).ExitCode.ToString());
this.Status = AzurePluginStatus.Error;
this.StatusMessage = "Hybris process exited!";
}
else
{
Trace.TraceAndLogWarning("HybrisPlugin", "Hybris process exited due to Additional Configuration change! ExitCode " + (sender as System.Diagnostics.Process).ExitCode.ToString());
this.Status = AzurePluginStatus.Warning;
this.StatusMessage = "Hybris process exited!";
}
};
if (_HybrisJavaProcess.Start())
{
_HybrisJavaProcess.BeginOutputReadLine();
_HybrisJavaProcess.BeginErrorReadLine();
}
else
{
Trace.TraceAndLogError("HybrisPlugin", "Hybris process could not be started!");
this.Status = AzurePluginStatus.ErrorStarting;
this.StatusMessage = "Hybris process could not be started!";
return false;
}
Trace.TraceAndLogInformation("HybrisPlugin", "Hybris process started.");
}
catch(Exception ex)
{
Trace.TraceAndLogError("HybrisPlugin", "Error while creating HybrisJavaProcess: " + ex.ToString());
this.Status = AzurePluginStatus.ErrorStarting;
this.StatusMessage = "Error while creating HybrisJavaProcess.";
return false;
}
this.Status = AzurePluginStatus.Healthy;
this.StatusMessage = "Process ID: " + _HybrisJavaProcess.Id.ToString();
return true;
}
开发者ID:GirishDamuluri,项目名称:microsoft-deployment-accelerator-for-hybris-on-azure,代码行数:75,代码来源:HybrisPlugin.cs
示例13: setAuthorInfo
/// <summary>
/// Read the author information from the debug token and update the appropriate boxes.
/// </summary>
public void setAuthorInfo()
{
if (!File.Exists(_localRIMFolder + "DebugToken.bar"))
{
// Create the dialog instance without Help support.
var DebugTokenDialog = new DebugToken.DebugTokenDialog();
// Show the dialog.
if (!DebugTokenDialog.IsClosing)
DebugTokenDialog.ShowDialog();
}
System.Diagnostics.Process p = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = p.StartInfo;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardOutput = true;
p.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(p_OutputDataReceived);
/// Get Device PIN
startInfo.FileName = "cmd.exe";
startInfo.Arguments = string.Format(@"/C blackberry-airpackager.bat -listManifest ""{0}""", _localRIMFolder + "DebugToken.bar");
try
{
p.Start();
p.BeginErrorReadLine();
p.BeginOutputReadLine();
p.WaitForExit();
p.Close();
}
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine(startInfo.Arguments);
System.Diagnostics.Debug.WriteLine(e.Message);
}
}
示例14: Start
public void Start()
{
System.Diagnostics.Process pProcess = new System.Diagnostics.Process();
pProcess.StartInfo.FileName = Command;
pProcess.StartInfo.Arguments = Params;
pProcess.StartInfo.UseShellExecute = UseShellExecute;
pProcess.StartInfo.RedirectStandardOutput = RedirectStandardOutput;
pProcess.StartInfo.RedirectStandardError = RedirectStandardError;
pProcess.StartInfo.CreateNoWindow = CreateNoWindow;
pProcess.StartInfo.WindowStyle = WindowStyle;
if (RedirectStandardOutput)
{
pProcess.OutputDataReceived += (sender, args) =>
{
if (OnNewLine != null)
OnNewLine(args.Data);
};
pProcess.ErrorDataReceived += (sender, args) =>
{
if (OnNewLine != null)
OnNewLine(args.Data);
};
}
pProcess.Start();
if (RedirectStandardOutput)
{
pProcess.BeginOutputReadLine();
pProcess.BeginErrorReadLine();
}
SetProcessStatusInvoke(ProcessStatus.Running);
if(Async)
{
new Thread(() =>
{
pProcess.WaitForExit();
SetProcessStatusInvoke(ProcessStatus.Stop);
}).Start();
}
else
{
pProcess.WaitForExit();
SetProcessStatusInvoke(ProcessStatus.Stop);
}
}
示例15: Launch
//.........这里部分代码省略.........
else {
// if working dir is given and if the executable is within that folder, we make the executable path relative to the working dir
//program = Utilities.MakeRelativePath(workingDirectory, programPath); // [email protected]
program = programPath;
}
if (externalConsole) {
var result = Terminal.LaunchInTerminal(workingDirectory, mono_path, mono_args, program, arguments, env);
if (!result.Success) {
return Task.FromResult(new DebugResult(3002, "launch: can't launch terminal ({reason})", new { reason = result.Message }));
}
} else {
_process = new System.Diagnostics.Process();
_process.StartInfo.CreateNoWindow = true;
_process.StartInfo.UseShellExecute = false;
_process.StartInfo.WorkingDirectory = workingDirectory;
_process.StartInfo.FileName = mono_path;
_process.StartInfo.Arguments = string.Format("{0} {1} {2}", Terminal.ConcatArgs(mono_args), Terminal.Quote(program), Terminal.ConcatArgs(arguments));
_stdoutEOF = false;
_process.StartInfo.RedirectStandardOutput = true;
_process.OutputDataReceived += (object sender, System.Diagnostics.DataReceivedEventArgs e) => {
if (e.Data == null) {
_stdoutEOF = true;
}
SendOutput(OutputEvent.Category.stdout, e.Data);
};
_stderrEOF = false;
_process.StartInfo.RedirectStandardError = true;
_process.ErrorDataReceived += (object sender, System.Diagnostics.DataReceivedEventArgs e) => {
if (e.Data == null) {
_stderrEOF = true;
}
SendOutput(OutputEvent.Category.stderr, e.Data);
};
_process.EnableRaisingEvents = true;
_process.Exited += (object sender, EventArgs e) => {
Terminate("node process exited");
};
if (env != null) {
// we cannot set the env vars on the process StartInfo because we need to set StartInfo.UseShellExecute to true at the same time.
// instead we set the env vars on OpenDebug itself because we know that OpenDebug lives as long as a debug session.
foreach (var entry in env) {
System.Environment.SetEnvironmentVariable(entry.Key, entry.Value);
}
}
try {
_process.Start();
_process.BeginOutputReadLine();
_process.BeginErrorReadLine();
}
catch (Exception e) {
return Task.FromResult(new DebugResult(3002, "launch: can't launch terminal ({reason})", new { reason = e.Message }));
}
}
Debugger.Connect(IPAddress.Parse(host), port);
}
else { // Generic & Windows
CommandLine.WaitForSuspend();
if (workingDirectory == null) {
// if no working dir given, we use the direct folder of the executable
workingDirectory = Path.GetDirectoryName(programPath);
}
Debugger.WorkingDirectory = workingDirectory;
if (arguments != null) {
string pargs = "";
foreach (var a in arguments) {
if (args.Length > 0) {
pargs += ' ';
}
pargs += Terminal.Quote(a);
}
Debugger.Arguments = pargs;
}
if (environmentVariables != null) {
var dict = Debugger.EnvironmentVariables;
foreach (var entry in environmentVariables) {
dict.Add(entry.Key, entry.Value);
}
}
// [email protected] we should use the runtimeExecutable
// [email protected] we should pass runtimeArgs
var file = new FileInfo(programPath);
Debugger.Run(file);
// [email protected] in case of errors?
}
return Task.FromResult(new DebugResult());
}