public void Start()
            {
                process.Start();
                process.BeginOutputReadLine();
                process.BeginErrorReadLine();

                if (debug)
                {
                    var maxWaitUntil = DateTime.Now.AddSeconds(30);
                    System.Threading.Thread.Sleep(100);
                    while (shouldAttachToMain == null && maxWaitUntil > DateTime.Now)
                    {
                        System.Threading.Thread.Sleep(100);
                    }
                    if (shouldAttachToMain != null && shouldAttachToMain.Value)
                    {
                        AttachToProcess(process.Id);
                    }
                }
            }
Example #2
0
        private void RunProcess(string exePath, string arguments)
        {
            WriteToOutputWindow("Starting build...");
            WriteToOutputWindow(exePath + " " + arguments);
            WriteToOutputWindow(string.Empty);

            using (System.Diagnostics.Process proc = new System.Diagnostics.Process())
            {
                proc.StartInfo.FileName               = exePath;
                proc.StartInfo.Arguments              = arguments;
                proc.StartInfo.UseShellExecute        = false;
                proc.StartInfo.CreateNoWindow         = true;
                proc.StartInfo.RedirectStandardOutput = true;

                proc.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_OutputDataReceived);
                proc.Start();

                proc.BeginOutputReadLine();
                proc.WaitForExit();
            }
        }