By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,965 Members | 2,055 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,965 IT Pros & Developers. It's quick & easy.

Reading Stream After RedirectStandardOutput=True Blocks

P: n/a
If I open a DOS console window (CMD) and enter "Netdiag /v", I get periodic
output showing the progress of the diagnostic tests being run.

If I create a Windows Forms app to run Netdiag using
System.Diagnostics.Process I can only get the output in a single block. That
is to say, if I redirect standard output to a stream, I can call ReadToEnd()
on the stream and when the process has finished I get a splurge of text to
output to the screen.

If I use Peek() in a loop to see when there is a character to read, it
always returns -1. It appears that although Netdiag is generating output, it
is not getting written to the stream.

Is there some way to read the output as it is generated, rather than all in
one hit at the end? I have tried putting each of the bits in their own
threads but it doesn't seem to make any difference.

TIA

Charles
Mar 16 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Problem solved. A great example can be found here (The Code Project) for
anyone who is interested.

http://209.171.52.99/csharp/LaunchPr...asp?print=true

Charles
"Charles Law" <bl***@nowhere.com> wrote in message
news:eh**************@TK2MSFTNGP10.phx.gbl...
If I open a DOS console window (CMD) and enter "Netdiag /v", I get
periodic output showing the progress of the diagnostic tests being run.

If I create a Windows Forms app to run Netdiag using
System.Diagnostics.Process I can only get the output in a single block.
That is to say, if I redirect standard output to a stream, I can call
ReadToEnd() on the stream and when the process has finished I get a
splurge of text to output to the screen.

If I use Peek() in a loop to see when there is a character to read, it
always returns -1. It appears that although Netdiag is generating output,
it is not getting written to the stream.

Is there some way to read the output as it is generated, rather than all
in one hit at the end? I have tried putting each of the bits in their own
threads but it doesn't seem to make any difference.

TIA

Charles

Mar 16 '06 #2

P: n/a
"Charles Law" <bl***@nowhere.com> schrieb:
If I open a DOS console window (CMD) and enter "Netdiag /v", I get
periodic output showing the progress of the diagnostic tests being run.
[...]
Is there some way to read the output as it is generated, rather than all
in one hit at the end? I have tried putting each of the bits in their own
threads but it doesn't seem to make any difference.


<URL:http://dotnet.mvps.org/dotnet/samples/misc/RedirectConsole.zip>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Mar 16 '06 #3

P: n/a
Hi Herfried

Thanks for the link. I have just tried it, and it exhibits the same problem
I am now getting. It doesn't show the full output.

Try this

netdiag /v

and see what happens. The last thing you should see is "... command
completed successfully". Instead it stops short of the end, sometimes
mid-word.

Any thoughts?

Charles
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:e1**************@tk2msftngp13.phx.gbl...
"Charles Law" <bl***@nowhere.com> schrieb:
If I open a DOS console window (CMD) and enter "Netdiag /v", I get
periodic output showing the progress of the diagnostic tests being run.
[...]
Is there some way to read the output as it is generated, rather than all
in one hit at the end? I have tried putting each of the bits in their own
threads but it doesn't seem to make any difference.


<URL:http://dotnet.mvps.org/dotnet/samples/misc/RedirectConsole.zip>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Mar 16 '06 #4

P: n/a
Herfried

Can you confirm that you get the same? Is there a fix?

Charles
"Charles Law" <bl***@nowhere.com> wrote in message
news:uX**************@TK2MSFTNGP12.phx.gbl...
Hi Herfried

Thanks for the link. I have just tried it, and it exhibits the same
problem I am now getting. It doesn't show the full output.

Try this

netdiag /v

and see what happens. The last thing you should see is "... completed
successfully".
Instead it stops short of the end, sometimes mid-word.

Any thoughts?

Charles
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:e1**************@tk2msftngp13.phx.gbl...
"Charles Law" <bl***@nowhere.com> schrieb:
If I open a DOS console window (CMD) and enter "Netdiag /v", I get
periodic output showing the progress of the diagnostic tests being run.
[...]
Is there some way to read the output as it is generated, rather than all
in one hit at the end? I have tried putting each of the bits in their
own threads but it doesn't seem to make any difference.


<URL:http://dotnet.mvps.org/dotnet/samples/misc/RedirectConsole.zip>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


Mar 17 '06 #5

P: n/a
Charles,

I want to show you this. Being busy with it, I saw a problem you had in past
that is done in this (Bitconverter). Beside that do in my opinion all
webbrowsers solutions interest you .

http://www.vb-tips.com/default.aspx?...d-da738cdc7c2c

Cor

"Charles Law" <bl***@nowhere.com> schreef in bericht
news:ul*************@TK2MSFTNGP12.phx.gbl...
Herfried

Can you confirm that you get the same? Is there a fix?

Charles
"Charles Law" <bl***@nowhere.com> wrote in message
news:uX**************@TK2MSFTNGP12.phx.gbl...
Hi Herfried

Thanks for the link. I have just tried it, and it exhibits the same
problem I am now getting. It doesn't show the full output.

Try this

netdiag /v

and see what happens. The last thing you should see is "... completed
successfully".
Instead it stops short of the end, sometimes mid-word.

Any thoughts?

Charles
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:e1**************@tk2msftngp13.phx.gbl...
"Charles Law" <bl***@nowhere.com> schrieb:
If I open a DOS console window (CMD) and enter "Netdiag /v", I get
periodic output showing the progress of the diagnostic tests being run.
[...]
Is there some way to read the output as it is generated, rather than
all in one hit at the end? I have tried putting each of the bits in
their own threads but it doesn't seem to make any difference.

<URL:http://dotnet.mvps.org/dotnet/samples/misc/RedirectConsole.zip>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>



Mar 17 '06 #6

P: n/a
Hi Cor

Yes, they do, although I am not currently working in that area, I still play
around with it from time-to-time.

Charles
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Charles,

I want to show you this. Being busy with it, I saw a problem you had in
past that is done in this (Bitconverter). Beside that do in my opinion all
webbrowsers solutions interest you .

http://www.vb-tips.com/default.aspx?...d-da738cdc7c2c

Cor

"Charles Law" <bl***@nowhere.com> schreef in bericht
news:ul*************@TK2MSFTNGP12.phx.gbl...
Herfried

Can you confirm that you get the same? Is there a fix?

Charles
"Charles Law" <bl***@nowhere.com> wrote in message
news:uX**************@TK2MSFTNGP12.phx.gbl...
Hi Herfried

Thanks for the link. I have just tried it, and it exhibits the same
problem I am now getting. It doesn't show the full output.

Try this

netdiag /v

and see what happens. The last thing you should see is "... completed
successfully".
Instead it stops short of the end, sometimes mid-word.

Any thoughts?

Charles
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:e1**************@tk2msftngp13.phx.gbl...
"Charles Law" <bl***@nowhere.com> schrieb:
> If I open a DOS console window (CMD) and enter "Netdiag /v", I get
> periodic output showing the progress of the diagnostic tests being
> run.
>[...]
> Is there some way to read the output as it is generated, rather than
> all in one hit at the end? I have tried putting each of the bits in
> their own threads but it doesn't seem to make any difference.

<URL:http://dotnet.mvps.org/dotnet/samples/misc/RedirectConsole.zip>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>



Mar 17 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.