My console program outputs "*" symbols to indicate progress.
I'd like to read this in order to update the progress bar in a Windows form:

int Progress=0;
System.Diagnostics.Process ProcessObj = new System.Diagnostics.Process();
ProcessObj.StartInfo.UseShellExecute = false;
ProcessObj.StartInfo.CreateNoWindow = true;
ProcessObj.StartInfo.RedirectStandardOutput = true;
ProcessObj.Start();
while(!ProcessObj.HasExited){
   Progress+= ProcessObj.StandardOutput.ReadBlock(buffer, index, 1);
}
Progress+= ProcessObj.StandardOutput.ReadBlock(buffer, index, 1);

Usually, it waits till the process exits before reading anything at all (same for Read), though sometimes it will read the first 1 to 3 characters first.

Anyone know what is causing this?

You probably need to use an asynchronous read by calling BeginOutputReadLine and setting an OutputDataReceived event handler.
I have no experience with it, so I can only direct you to the MSDN help.
MSDN Process.BeginOutputReadLine
Maybe someone else can offer some more experienced advice.

I've tried ".BeginOutputReadLine()" with new ".OutputDataReceived" event (which only responds after a line-end, unfortunately), and I've tried calling ".StandardOutput.Read()" from a new thread created just after ".Start()" was called.

Both of these processed output asynchronously for my test console program, but waited till the program I'm interested in (which involves usb communication) was complete before responding.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.