Click here to Skip to main content
15,898,538 members
Home / Discussions / C#
   

C#

 
Questionc# controlbox and window menu Pin
Zeyad Jalil23-Nov-10 22:35
professionalZeyad Jalil23-Nov-10 22:35 
AnswerRe: c# controlbox and window menu Pin
Pete O'Hanlon24-Nov-10 3:32
mvePete O'Hanlon24-Nov-10 3:32 
QuestionHOWTO: start, get partial output and kill a console application from c# Pin
jancg23-Nov-10 22:06
jancg23-Nov-10 22:06 
AnswerRe: HOWTO: start, get partial output and kill a console application from c# Pin
Fla_Golfr23-Nov-10 22:38
professionalFla_Golfr23-Nov-10 22:38 
GeneralRe: HOWTO: start, get partial output and kill a console application from c# Pin
jancg23-Nov-10 23:05
jancg23-Nov-10 23:05 
AnswerRe: HOWTO: start, get partial output and kill a console application from c# Pin
Luc Pattyn24-Nov-10 3:36
sitebuilderLuc Pattyn24-Nov-10 3:36 
GeneralRe: HOWTO: start, get partial output and kill a console application from c# Pin
jancg24-Nov-10 4:22
jancg24-Nov-10 4:22 
GeneralRe: HOWTO: start, get partial output and kill a console application from c# Pin
jancg24-Nov-10 10:06
jancg24-Nov-10 10:06 
The code below will display "Started!" in the textbox immediately. Next it will hit the TimerCallBack method every second after the initial 5 seconds of computation. As it is supposed to. Saidly Peek() return -1 up to the moment the console program finishesFrown | :( I know for sure output has already been written!

If I test the same from a command window, adding " > output.log" to the command line, the output goes into output.log but not untill the program finishes Frown | :(

If I start the program normally from a command window, output is written to the console line-by-line!

using System;
using System.Diagnostics;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
 public partial class Form1 : Form
 {

  public Form1()
  {
   InitializeComponent();
  }

  private Process process;

  private void Form1_Load(object sender, EventArgs e)
  {
   process = new Process();
   process.StartInfo.FileName = @"D:\Users\Jan C. de Graaf\Documents\Othello\test\zebra.exe";
   process.StartInfo.Arguments = "-b 0 -h 24 -l 28 30 30 28 30 30 -r 0 -slack 0.0 -learn 26 22 -private -log hqbook.txt -test";
   process.StartInfo.WorkingDirectory = @"D:\Users\Jan C. de Graaf\Documents\Othello\test";
   process.StartInfo.UseShellExecute = false;
   process.StartInfo.RedirectStandardOutput = true;
   process.Start();

   new System.Threading.Timer(new System.Threading.TimerCallback(TimerCallback), null, 5000, 1000);

   textBox1.Text = "Started!\r\n";
  }

  void TimerCallback(object state)
  {
   while (process.StandardOutput.Peek() > -1)
   {
    var data = process.StandardOutput.ReadLine();
    textBox1.Invoke((MethodInvoker)delegate{textBox1.Text += data + "\r\n";});
   }
  }
 }
}

AnswerRe: HOWTO: start, get partial output and kill a console application from c# Pin
Luc Pattyn24-Nov-10 10:43
sitebuilderLuc Pattyn24-Nov-10 10:43 
GeneralRe: HOWTO: start, get partial output and kill a console application from c# Pin
jancg24-Nov-10 12:07
jancg24-Nov-10 12:07 
GeneralRe: HOWTO: start, get partial output and kill a console application from c# Pin
Luc Pattyn24-Nov-10 12:29
sitebuilderLuc Pattyn24-Nov-10 12:29 
AnswerRe: HOWTO: start, get partial output and kill a console application from c# Pin
PIEBALDconsult24-Nov-10 11:59
mvePIEBALDconsult24-Nov-10 11:59 
QuestionMessage Removed Pin
23-Nov-10 20:19
NarVish23-Nov-10 20:19 
AnswerRe: Logging the start & end of the function of an application. Pin
JF201523-Nov-10 20:24
JF201523-Nov-10 20:24 
QuestionNeed Typing Tutor Method / Examples Pin
M Riaz Bashir23-Nov-10 18:46
M Riaz Bashir23-Nov-10 18:46 
AnswerRe: Need Typing Tutor Method / Examples Pin
Keith Barrow23-Nov-10 21:49
professionalKeith Barrow23-Nov-10 21:49 
QuestionGet color value from array Pin
pancakeleh23-Nov-10 16:49
pancakeleh23-Nov-10 16:49 
AnswerRe: Get color value from array Pin
JF201523-Nov-10 18:25
JF201523-Nov-10 18:25 
GeneralRe: Get color value from array Pin
pancakeleh23-Nov-10 18:31
pancakeleh23-Nov-10 18:31 
GeneralRe: Get color value from array Pin
JF201523-Nov-10 18:37
JF201523-Nov-10 18:37 
GeneralRe: Get color value from array [modified] Pin
pancakeleh23-Nov-10 18:52
pancakeleh23-Nov-10 18:52 
GeneralRe: Get color value from array Pin
_Erik_24-Nov-10 3:48
_Erik_24-Nov-10 3:48 
GeneralRe: Get color value from array [modified] Pin
pancakeleh24-Nov-10 16:11
pancakeleh24-Nov-10 16:11 
GeneralRe: Get color value from array [modified] Pin
_Erik_25-Nov-10 4:51
_Erik_25-Nov-10 4:51 
QuestionWhat Class(es) to use for Hardware Profiling? Pin
dpminusa23-Nov-10 15:48
dpminusa23-Nov-10 15:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.