title: reading multiple times from same stream in c#
body: <p>i want to read the output of my program multiple times. Some thing like if i pass X i get the output and i display it, then again if i pass Y i get the output and i display it. without restarting the process.
  to try it i have made a c program</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  int main()
  {
      int i;
      int j;
  while(scanf("%d", &amp;i))
  {
      for(j = 0; j&lt;=i;j++)
      printf("%d\n",j);
  }
  return 0;
  }
  </code></pre>
  
  <p>and now i'm interfacting it with C#, where when i enter a text in the textbox it is passed through the redirect standardinput (a streamwriter) to the program and to read the output i call it's standardoutput (a streamreader).readtoend().</p>
  
  <p>But it is not working for me. As it goes in waitstate till the stream returns some indication telling end has been read.</p>
  
  <p>How can i achieve such a thing?</p>
  
  <p>I tried the asynchronous read too where i call the beginoutputread method, but then i won't know when the read has been finished! One way can be for me to add a marker in my original program to indicate that output is over for the current input. Is there any other way for me to achieve it?</p>