473,394 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Problems reading StandardOutput and StandardError at runtime

I've recently discovered the value of using existing console
applications in managed .net apps. Unfortunately, I've stumbled into a
problem with a particular console application that check's crc info on
CDs. Using either the StandardError or StandardOutput streams read,
readline or peek methods causes an immediate block that doesn't
release until the console app finishes it's business. I want to launch
this console app and update my UI to show it's still working. The read
methods currently get launched on another thread so the UI doesn't
freeze but either way the problem existed. If I run the executable
directly in the cmd.exe environment, I know that cmd.exe is working
interactively with the console application and kicking back the
results of the process. Any ideas or comments would be greatly
appreciated.

To sum up, I call read on either standarderror or standardoutput, I've
tried either stream first to make sure one wasn't filling up the
stream buffer and blocking the other. The read method blocks the
entire time the crc console application is running, probably 5
minutes. When the read method finally releases and my read loop can
iterate across the stream, I get the text that would normally display
at a command prompt interactively or as they occur.

Is this a bug in how the Process object interacts with the console
app?

I've used this model before where I read lines from the StandardOutput
stream as they occur when doing things like using dir /s c:\ and it
works fine. Or another application runs chkdsk and I get the 10%, 20%,
30% lines as they occur.

Some examples:

Process myProcess = new Process();
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(@"path to
exe" );
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.RedirectStandardError = true;
myProcessStartInfo.RedirectStandardOutput = true;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();

this .....>
ReaderThread oOut = new ReaderThread(myProcess.StandardOutput);
oOut.OutputLogFile = "OutLog.txt";
oOut.ReadComplete+=new
ISOTest.ReaderThread.ReadCompleteEventHandler(oOut _ReadComplete);
Thread tOut = new Thread(new ThreadStart(oOut.ReadOutput));
tOut.Start();

or this ....>

while (myProcess.StandartOutput.Peek() != -1)
{
myProcess.StandartOutput.Read(x, y, z);
or....>
myProcess.StandardOutput.ReadLine();
}

or any call(read, peek, readline) that attempts to read from the
stream. They all block

Thanks,

John
Nov 22 '05 #1
0 1349

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: John Lewin | last post by:
I've recently discovered the value of using existing console applications in managed .net apps. Unfortunately, I've stumbled into a problem with a particular console application that check's crc...
1
by: Panagiotis | last post by:
Hi everyone, this is what I want to do in C#: 1) start a Cygwin Bash Shell 2) send the Shell a command, for example "ls -l" 3) capture all the output of the command The code below seems to...
16
by: sunil | last post by:
Hi, I have a service written in c# that I need to run as a "Network Service". I am using a setup project to install the service. If I install the service in User's Personal Folder, I get the...
1
by: Claire | last post by:
Hi, I'm trying to run mysqldump.exe from my c# application, running on windows vista with visual studio 2005. The following code does not produce the output file. The same line used in a command...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.