title: Get the output of minerd.exe synchronous
body: <p>Basically Im trying to start a process and get the output. The program is minerd.exe (bitcoin cpu miner) <a href="https://github.com/pooler/cpuminer" rel="nofollow">https://github.com/pooler/cpuminer</a> for reference
  I tried something like this : </p>
  
  <pre><code>private  void StartMining()
          {
  
              Process p = new Process();
              StreamWriter sw;
              StreamReader sr;
              StreamReader err;
              ProcessStartInfo psI = new ProcessStartInfo(@"miners\minerd.exe");
              psI.Arguments = "-o " + miner.PoolIp + ":" + miner.PoolServerPort + " -O " + miner.PoolUsername + ":" + miner.PoolPassword;
              psI.UseShellExecute = false;
              psI.RedirectStandardInput = true;
              psI.RedirectStandardOutput = true;
              psI.RedirectStandardError = true;
              psI.CreateNoWindow = true;
              p.StartInfo = psI;
              p.OutputDataReceived += new DataReceivedEventHandler(proc_OutputDataReceived);
  
              p.ErrorDataReceived += new DataReceivedEventHandler(proc_ErrorDataReceived);
              p.Start();
  
  
              p.BeginOutputReadLine();
  
          }
  
          private void proc_ErrorDataReceived(object sender, DataReceivedEventArgs e)
          {
              WriteLogWindow(e.Data, Color.Green);
          }
  
          private void proc_OutputDataReceived(object sender, DataReceivedEventArgs e)
          {
              WriteLogWindow(e.Data, Color.Red);
          }
   private delegate void DelegateInsertNewLineToLogRichTextBox(string text, Color color);
          void WriteLogWindow(string text, Color color)
          {
              if (this.richTextBox1.InvokeRequired)
              {
                  DelegateInsertNewLineToLogRichTextBox method = new DelegateInsertNewLineToLogRichTextBox(InvokedInsertNewLineToLgoRichTextBox);
                  Invoke(method, new object[2] { text, color });
  
              }
              else
              {
                  InvokedInsertNewLineToLgoRichTextBox(text, color);
  
              }
          }
          private void InvokedInsertNewLineToLgoRichTextBox(string message, Color color)
          {
              richTextBox1.Font = new Font("Arial", 8F, FontStyle.Bold);
              richTextBox1.SelectionColor = color;
              richTextBox1.SelectedText = Environment.NewLine + message + "\t" + DateTime.Now.ToString("HH:mm:ss d/M/yyyy");
              richTextBox1.ScrollToCaret();
          }
  </code></pre>
  
  <p>The miner seems to be working but i get no output.</p>
  
  <p>Thanks in advance for any advices</p>