Home All Groups Group Topic Archive Search About

Reading Stream After RedirectStandardOutput=True Blocks

Author
16 Mar 2006 9:42 AM
Charles Law
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

Author
16 Mar 2006 10:39 AM
Charles Law
Problem solved. A great example can be found here (The Code Project) for
anyone who is interested.

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

Charles


Show quoteHide quote
"Charles Law" <bl***@nowhere.com> wrote in message
news:ehSdx3NSGHA.5156@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
>
>
Author
16 Mar 2006 3:08 PM
Herfried K. Wagner [MVP]
"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/>
Author
16 Mar 2006 3:23 PM
Charles Law
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


Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:e1sfIuQSGHA.1576@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/>
Author
17 Mar 2006 4:28 PM
Charles Law
Herfried

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

Charles


Show quoteHide quote
"Charles Law" <bl***@nowhere.com> wrote in message
news:uX60R2QSGHA.5808@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]" <hirf-spam-me-here@gmx.at> wrote in message
> news:e1sfIuQSGHA.1576@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/>
>
>
Author
17 Mar 2006 4:36 PM
Cor Ligthert [MVP]
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?ID=58514c5a-5f5d-4b6d-a7bd-da738cdc7c2c

Cor

Show quoteHide quote
"Charles Law" <bl***@nowhere.com> schreef in bericht
news:ulx4F$dSGHA.424@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:uX60R2QSGHA.5808@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]" <hirf-spam-me-here@gmx.at> wrote in message
>> news:e1sfIuQSGHA.1576@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/>
>>
>>
>
>
Author
17 Mar 2006 4:57 PM
Charles Law
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


Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:%239KErCeSGHA.1204@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?ID=58514c5a-5f5d-4b6d-a7bd-da738cdc7c2c
>
> Cor
>
> "Charles Law" <bl***@nowhere.com> schreef in bericht
> news:ulx4F$dSGHA.424@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:uX60R2QSGHA.5808@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]" <hirf-spam-me-here@gmx.at> wrote in message
>>> news:e1sfIuQSGHA.1576@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/>
>>>
>>>
>>
>>
>
>