当前位置: 首页>>代码示例>>C#>>正文


C# System.Diagnostics.Process.BeginOutputReadLine方法代码示例

本文整理汇总了C#中System.Diagnostics.Process.BeginOutputReadLine方法的典型用法代码示例。如果您正苦于以下问题:C# System.Diagnostics.Process.BeginOutputReadLine方法的具体用法?C# System.Diagnostics.Process.BeginOutputReadLine怎么用?C# System.Diagnostics.Process.BeginOutputReadLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Diagnostics.Process的用法示例。


在下文中一共展示了System.Diagnostics.Process.BeginOutputReadLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Read

        /// <summary>
        /// 読み取り開始
        /// </summary>
        public void Read()
        {
            Console.WriteLine("FelicaReader::Read() - start");
            //  プロセスオブジェクトを生成
            System.Diagnostics.Process p = new System.Diagnostics.Process();
            //  実行ファイルを指定
            p.StartInfo.FileName = this.tagtool;
            //  シェルコマンドを無効に
            p.StartInfo.UseShellExecute = false;
            //  入力をリダイレクト
            p.StartInfo.RedirectStandardInput = true;
            //  出力をリダイレクト
            p.StartInfo.RedirectStandardOutput = true;
            //  OutputDataReceivedイベントハンドラを追加
            p.OutputDataReceived += OutputDataReceivedHandler;
            //  プロセスを実行
            p.Start();
            //  非同期で出力の読み取りを開始
            p.BeginOutputReadLine();
            //  入力を行う為のストリームライターとプロセスの標準入力をリンク
            System.IO.StreamWriter myStreamWriter = p.StandardInput;

            myStreamWriter.Close();
            p.WaitForExit();
            p.Close();
            Console.WriteLine("FelicaReader::Read() - end");
        }
开发者ID:takanemu,项目名称:Attendance,代码行数:30,代码来源:FelicaReader.cs

示例2: 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();
        }
开发者ID:sauberwind,项目名称:Nov2Epub,代码行数:61,代码来源:EpubCheckWrapper.cs

示例3: ExecuteCommand

        /// <summary>
        /// Execute a Commad
        /// </summary>
        public List<string> ExecuteCommand(string cmd, string args)
        {
            answer.Clear();
            System.Diagnostics.Process process = null;
            System.Diagnostics.ProcessStartInfo processStartInfo;
            processStartInfo = new System.Diagnostics.ProcessStartInfo();

            processStartInfo.FileName = cmd;
            if (System.Environment.OSVersion.Version.Major >= 6)  // Windows Vista or higher
            {
                processStartInfo.Verb = "runas";
            }

            processStartInfo.Arguments = args;
            processStartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
            processStartInfo.UseShellExecute = false;
            processStartInfo.RedirectStandardOutput = true;
            processStartInfo.RedirectStandardError = true;
            processStartInfo.RedirectStandardInput = true;

            process = new System.Diagnostics.Process();
            process.StartInfo = processStartInfo;
            process.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(process_OutputDataReceived);

            try
            {
                process.Start();

                StreamWriter streamWriter = process.StandardInput;
                process.BeginOutputReadLine();
                streamWriter.Close();
                process.WaitForExit();

                string error = process.StandardError.ReadToEnd();
                if (!error.Equals(""))
                {
                    answer.Add("Errors Found: " + error);
                }
            }
            catch (Exception ex)
            {
                answer.Add("Exception: " + ex.Message);
            }

            if (process != null)
            {
                process.Dispose();
            }

            return answer;
        }
开发者ID:jmecosta,项目名称:VSSonarAddin,代码行数:54,代码来源:CommandExecution.cs

示例4: 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();
        }
开发者ID:Kuchinashi,项目名称:AndroidExplorer,代码行数:44,代码来源:DoCommand.cs

示例5: 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;
				}
			}
		}
开发者ID:transformersprimeabcxyz,项目名称:_To-Do-unreal-3D-niftyplugins-ben-marsh,代码行数:39,代码来源:Process.cs

示例6: Handle

        public override void Handle(TemplateAction action) {
            _process.Logger.Info("Running {0}.", action.File);

            var fileInfo = new FileInfo(action.File);

            if (fileInfo.Exists) {
                var executable = new System.Diagnostics.Process {
                    StartInfo = {
                        UseShellExecute = false,
                        RedirectStandardOutput = true,
                        FileName = fileInfo.FullName,
                        Arguments = action.Arguments,
                        CreateNoWindow = true
                    }
                };

                executable.OutputDataReceived += (sender, args) => _process.Logger.Info(args.Data);
                executable.Start();
                executable.BeginOutputReadLine();
                executable.WaitForExit();
            } else {
                _process.Logger.Warn("Couldn't find and execute {0}.", action.File);
            }
        }
开发者ID:modulexcite,项目名称:Transformalize,代码行数:24,代码来源:TemplateActionExecute.cs

示例7: GnuShogiPlayer

        public GnuShogiPlayer()
        {
            ShogiProc = new System.Diagnostics.Process();
            ShogiProc.StartInfo.FileName = "gnushogi";
            ShogiProc.StartInfo.UseShellExecute = false;
            ShogiProc.StartInfo.RedirectStandardError = true;
            ShogiProc.StartInfo.RedirectStandardInput = true;
            ShogiProc.StartInfo.RedirectStandardOutput = true;

            ShogiProc.EnableRaisingEvents = true;
            ShogiProc.OutputDataReceived += HandleShogiProcOutputDataReceived;

            ShogiProc.Exited += HandleShogiProcExited;
            ShogiProc.Start();
            ShogiProc.BeginOutputReadLine();

            //read welcome message
            ReadFromShogiProc();

            ReadNextMoveThreadWaitHandle = new AutoResetEvent(false);
            ReadNextMoveThread = new Thread(new ThreadStart(ReadNextMoveThreadFunc));
            ReadNextMoveThread.IsBackground = true;
            ReadNextMoveThread.Start();
        }
开发者ID:Rootie,项目名称:KoushuShogi,代码行数:24,代码来源:GnuShogiPlayer.cs

示例8: Main

        static void Main(string[] args)
        {
            var outText = new StringBuilder();

              try {
            var asseblyLocation = typeof (Program).Assembly.Location;
            var sdkLocation = Path.GetFullPath(Path.Combine(
              Path.GetDirectoryName(asseblyLocation), @"..\..\..\..\..\..\unityfull"
              ));

            sdkLocation =
              Environment.GetEnvironmentVariable("UNITY_NEW_MONO_SDK") ??
              sdkLocation;

            var mcsLocation = Environment.GetEnvironmentVariable("UNITY_NEW_MONO")
                          ??
                          Environment.ExpandEnvironmentVariables(
                            @"%ProgramFiles%\Mono\lib\mono\4.5\mcs.exe");

            var procStartInfo =
              new System.Diagnostics.ProcessStartInfo(mcsLocation);
            //        new System.Diagnostics.ProcessStartInfo(@"C:\Program Files (x86)\Mono\bin\mono.exe");
            //        new System.Diagnostics.ProcessStartInfo(@"C:\Program Files (x86)\Mono\bin\mcs.bat");

            procStartInfo.Arguments = [email protected]"""-sdk:{sdkLocation}"" --runtime:v2 " + string.Join(" ", args);

            //      procStartInfo.Arguments = @"""C:\Program Files (x86)\Mono\lib\mono\4.5\mcs.exe"" " + procStartInfo.Arguments;

            procStartInfo.UseShellExecute = false;
            //      procStartInfo.CreateNoWindow = true;
            procStartInfo.RedirectStandardError = true;
            procStartInfo.RedirectStandardOutput = true;

            var proc = new System.Diagnostics.Process();
            proc.StartInfo = procStartInfo;
            proc.Start();

            var output = new StringBuilder();
            var error = new StringBuilder();

            proc.OutputDataReceived += (sender, e) => {
              Console.WriteLine(e.Data);
              output.AppendLine(e.Data);
            };

            proc.ErrorDataReceived += (sender, e) => {
              Console.Error.WriteLine(e.Data);
              error.AppendLine(e.Data);
            };

            proc.BeginErrorReadLine();
            proc.BeginOutputReadLine();

            proc.WaitForExit();

            outText.AppendLine(procStartInfo.Arguments);

            var corlib_path =
              Path.GetDirectoryName(typeof (object).Assembly.Location);
            string fx_path = corlib_path.Substring(0,
              corlib_path.LastIndexOf(Path.DirectorySeparatorChar));
            outText.AppendLine(fx_path);
            outText.AppendLine(asseblyLocation);
            outText.AppendLine(sdkLocation);

            //      var dict = Environment.GetEnvironmentVariables();
            //      foreach (var k in dict.Keys) {
            //        outText.AppendLine(k + " " + dict[k]);
            //      }
            outText.AppendLine(Environment.CurrentDirectory);

            outText.AppendLine();
            outText.AppendLine("[Output start]");
            outText.AppendLine();
            outText.Append(output);
            outText.AppendLine("[Output end]");

            outText.AppendLine();
            outText.AppendLine("[Error start]");
            outText.AppendLine();
            outText.Append(error);
            outText.AppendLine("[Error end]");
              }
              catch (Exception e) {
            outText.AppendLine();
            outText.AppendLine("[Exception !!!]");
            outText.Append(e);
              }

              System.IO.File.WriteAllText(
              Environment.ExpandEnvironmentVariables(
            @"%TEMP%\UnityMonoUpdatedCompilerOutput.txt"), outText.ToString());
        }
开发者ID:pizcogirl,项目名称:unity-mono-compiler-wrapper,代码行数:93,代码来源:Program.cs

示例9: CheckEpub

        //CheckEpubを実施、Output/Errorを表示する
        public static bool CheckEpub(string ePubFile)
        {
            var ret = true; //仮にエラーなしとする

            //メッセージ初期化
            outputLines = new List<string>();
            errorLines = new List<string>();

            //EPUBチェック実施中パネルを表示する
            var checkingDlg = new EpubCheckingDialog();
            checkingDlg.Show();

            var javaPath = PostProcess.javaPath;
            var ePubCheckPath = PostProcess.ePubCheckPath;

            //実行ファイル
            var p = new System.Diagnostics.Process();
            p.StartInfo.FileName = javaPath;

            //引数
            var args = "-jar "
                        + "\"" + ePubCheckPath + "\" "
                        + " \"" + ePubFile + "\"";
            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;

            //EpubCheckを実行する
            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");
                }
                ret = false;    //戻り値をエラーありにする。
            }
            else //エラーなし
            {
                resultDlg.errorTextBox.Text = "エラーはありませんでした。";
            }
            checkingDlg.Close();        //EpubCheck実施中のダイアログを閉じる
            resultDlg.ShowDialog();     //EpubCheck結果を表示する

            return (ret);
        }
开发者ID:sauberwind,项目名称:SakuraEpubUtility,代码行数:75,代码来源:EpubCheckWrapper.cs

示例10: Initialize


//.........这里部分代码省略.........
            }
            catch (Exception ex)
            {
                Trace.TraceAndLogError("HybrisPlugin", "Error installing StopTanukiWrapper.jar: " + ex.ToString());
                this.Status = AzurePluginStatus.ErrorInitializing;
                this.StatusMessage = "Error installing StopTanukiWrapper.jar";
                return false;
            }
            #endregion

            // 5. actually build the hybris platform
            #region Build hybris
            // Build hybris platform
            Trace.TraceInformation("HybrisPlugin: Building hybris platform.");
            try
            {
                var buildOutput = new StringBuilder();
                var buildError = new StringBuilder();
                using (var buildProcess = new System.Diagnostics.Process
                {
                    StartInfo = new System.Diagnostics.ProcessStartInfo
                    {
                        WorkingDirectory = hybrisWorkingDirectory,
                        FileName = hybrisBuildCommandFileName,
                        Arguments = string.Empty,
                        UseShellExecute = false,
                        LoadUserProfile = false,
                        RedirectStandardOutput = true,
                        RedirectStandardError = true,
                        RedirectStandardInput = true,
                        CreateNoWindow = true,
                        WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden,
                    },
                    EnableRaisingEvents = true,
                })
                {
                    buildProcess.OutputDataReceived += (s, a) => Trace.TraceVerbose("HybrisPlugin: Building hybris ouput line" + a.Data);
                    buildProcess.ErrorDataReceived += (s, a) => Trace.TraceAndLogError("HybrisPlugin", "Building hybris error line" + a.Data);

                    if (buildProcess.Start())
                    {
                        buildProcess.BeginOutputReadLine();
                        buildProcess.BeginErrorReadLine();
                        buildProcess.WaitForExit();
                    }

                    if (buildProcess.ExitCode == 0)
                        Trace.TraceAndLogInformation("HybrisPlugin", "Successfully built hybris platform.");
                    else
                        Trace.TraceAndLogError("HybrisPlugin", "Error executing build hybris platform command.");
                }
            }
            catch(Exception ex)
            {
                Trace.TraceAndLogError("Hybris", "Error building hybris platform. " + ex.ToString());
                this.Status = AzurePluginStatus.ErrorInitializing;
                this.StatusMessage = "Error building hybris platform.";
                return false;
            }
            #endregion

            // 6. Get from additional settings if we may start the hybris process
            #region Additional configuration
            AdditionalConfigurationManager.Instance.AdditionalConfigurationChanged += Instance_AdditionalConfigurationChanged;
            try
            {
                Trace.TraceInformation("HybrisPlugin: Processing initial additional configuration.");
                AdditionalConfigurationManager.Instance.ProcessConfiguration();
                Trace.TraceInformation("HybrisPlugin: Successfully processed initial additional configuration.");
            }
            catch(Exception ex)
            {
                Trace.TraceAndLogError("HybrisPlugin", "Error processing initial additional configuration: " + ex.ToString());
            }
            try
            {
                Trace.TraceInformation("HybrisPlugin", "Determining if Hybris was stopped before a reboot.");
                var stopHybris = AdditionalConfigurationManager.Instance.GetCurrentConfigurationValue("StopHybris");
                if (stopHybris == null)
                    Trace.TraceAndLogWarning("HybrisPlugin", "Determining if Hybris was stopped before a reboot resulted in a NULL value. Hybris will be started.");
                else
                {
                    Trace.TraceInformation("HybrisPlugin: Determining if Hybris was stopped before a reboot resulted in: " + stopHybris);
                    this.ConfigStopHybris = bool.Parse(stopHybris);
                }
            }
            catch (Exception ex)
            {
                Trace.TraceAndLogError("HybrisPlugin", "Error getting from Additional configuration if processes are to be started: " + ex.ToString());
                this.Status = AzurePluginStatus.ErrorInitializing;
                this.StatusMessage = "Error getting Additional configuration";
                return false;
            }
            #endregion

            Trace.TraceInformation("HybrisPlugin: Initialization done.");
            this.Status = AzurePluginStatus.NotStarted;
            this.StatusMessage = string.Empty;
            return true;
        }
开发者ID:GirishDamuluri,项目名称:microsoft-deployment-accelerator-for-hybris-on-azure,代码行数:101,代码来源:HybrisPlugin.cs

示例11: 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);
                }
            }
        }
开发者ID:bftt,项目名称:NetEnvSwitcher,代码行数:60,代码来源:EnvironmentConfigManager.cs

示例12: ExecuteTests

        public void ExecuteTests(string consolePath, string commandArgs, bool debug)
        {
            string command = string.Format("{0} {1}", consolePath, commandArgs);
            tracer.Trace(command, GetType().Name);

            var pane = outputWindowService.TryGetPane(OutputWindowDefinitions.SpecRunOutputWindowName);
            var displayResult = pane != null;
            var dispatcher = Dispatcher.CurrentDispatcher;

            var process = new System.Diagnostics.Process();
            process.StartInfo.FileName = consolePath;
            process.StartInfo.Arguments = commandArgs;
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.CreateNoWindow = true;

            if (displayResult)
            {
                pane.Clear();
                pane.Activate();
                dte.ToolWindows.OutputWindow.Parent.Activate();
                pane.WriteLine(command);
                process.OutputDataReceived += (sender, args) =>
                                                  {
                                                      if (args.Data != null)
                                                      {
                                                          dispatcher.BeginInvoke(new Action(() => pane.WriteLine(args.Data)), DispatcherPriority.ContextIdle);
                                                      }
                                                  };
            }

            process.Start();

            if (debug)
                AttachToProcess(process.Id);

            if (displayResult)
            {
                process.BeginOutputReadLine();
            }

            // async execution: we do not call 'process.WaitForExit();'
        }
开发者ID:hereyes,项目名称:SpecFlow,代码行数:43,代码来源:SpecRunTestRunnerGateway.cs

示例13: 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());
		}
开发者ID:TalanSoft,项目名称:vscode-mono-debug,代码行数:101,代码来源:MonoDebugSession.cs

示例14: getDeviceInfo

        /// <summary>
        /// Get the device Info of the connected device
        /// </summary>
        /// <returns>True if successful</returns>
        public bool getDeviceInfo()
        {
            bool success = 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(p_ErrorDataReceived);
            p.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(DeviceInfoDataReceived);

            /// Get Device PIN
            startInfo.FileName = "cmd.exe";
            startInfo.WorkingDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + "\\BlackBerry\\VSPlugin-NDK\\qnxtools\\bin\\";
            startInfo.Arguments = string.Format("/C blackberry-deploy.bat -listDeviceInfo {0} {1}", DeviceIP, DevicePassword == "" ? "" : "-password " + DevicePassword);

            try
            {
                p.Start();
                p.BeginErrorReadLine();
                p.BeginOutputReadLine();
                p.WaitForExit();
                if (p.ExitCode != 0)
                {
                    success = false;
                }
                else
                {
                    success = true;
                }

                p.Close();
                if (_errors != "")
                {
                    int begin = _errors.IndexOf("java.io.IOException: ");
                    if (begin != -1)
                    {
                        begin += 20;
                        int end = _errors.IndexOf("\n", begin);
                        MessageBox.Show(_errors.Substring(begin, end - begin) + "\n\nSee the Debug Output window for details.", "Could not get the device Info of the connected device.", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    else
                        MessageBox.Show(_errors + "See the Debug Output window for details.", "Could not get the device Info of the connected device.", MessageBoxButton.OK, MessageBoxImage.Error);

                    _errors = "";
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(startInfo.Arguments);
                System.Diagnostics.Debug.WriteLine(e.Message);
                success = false;
                if (_errors != "")
                {
                    int begin = _errors.IndexOf("java.io.IOException: ");
                    if (begin != -1)
                    {
                        begin += 20;
                        int end = _errors.IndexOf("\n", begin);
                        MessageBox.Show(_errors.Substring(begin, end - begin) + "\n\nSee the Debug Output window for details.", "Could not get the device Info of the connected device.", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    else
                        MessageBox.Show(_errors + "See the Debug Output window for details.", "Could not get the device Info of the connected device.", MessageBoxButton.OK, MessageBoxImage.Error);

                    _errors = "";
                }
            }

            return success;
        }
开发者ID:blackberry,项目名称:VSPlugin,代码行数:76,代码来源:UpdateManagerData.cs

示例15: uploadDebugToken

        /// <summary>
        /// Upload Token to connected device
        /// </summary>
        /// <returns>True if successful</returns>
        private bool uploadDebugToken()
        {
            bool success = false;

            if (string.IsNullOrEmpty(DeviceIP))
            {
                return success;
            }
            else if (!File.Exists(LocalFolder + "DebugToken.bar"))
            {
                return success;
            }

            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(p_ErrorDataReceived);
            p.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(p_OutputDataReceived);

            /// Request Debug Token
            startInfo.FileName = "cmd.exe";
            startInfo.WorkingDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + "\\BlackBerry\\VSPlugin-NDK\\qnxtools\\bin\\";
            startInfo.Arguments = string.Format(@"/C blackberry-deploy.bat -installDebugToken ""{0}"" -device {1} -password {2}", LocalFolder + "DebugToken.bar", DeviceIP, DevicePassword);

            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;
            }

            return success;
        }
开发者ID:blackberry,项目名称:VSPlugin,代码行数:56,代码来源:DebugTokenData.cs


注:本文中的System.Diagnostics.Process.BeginOutputReadLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。