Home All Groups Group Topic Archive Search About

Process.RedirectStandardOutput problem

Author
26 May 2006 9:09 PM
Terry Olsen
I'm trying to use the CDBURN.EXE from the SDK. I start the process and
redirect the output. I want to be able to get the output continuously so
I can update the GUI. But it seems to "spit out" the StandardOutput only
in large chunks. Here's my code... can someone give me some idea why
it's doing this and if it can be fixed?

Private Sub BurnCD(ByVal state As Object)
        Dim args As String = state
        Dim tmp As String = ""
        Dim buf() As Char = {""}

        BurnStartInfo.Arguments = args
        BurnProcess.Start()
        Dim sr As System.IO.StreamReader = BurnProcess.StandardOutput
        While sr.Peek > 0
            Try
                sr.Read(buf, 0, 1)
                tmp += buf(0)
                Debug.WriteLine(tmp)
            Catch ex As Exception
                Debug.WriteLine(ex.Message)
            End Try

            If tmp.EndsWith(vbCrLf) = True Then
                lblMsg.Text = tmp
                tmp = ""
            End If

            If tmp.EndsWith("done") Then
                lblProgress.Text = Val(tmp)
                tmp = ""
            End If
        End While
        sr.Close()
        BurnProcess.WaitForExit()

    End Sub

*** Sent via Developersdex http://www.developersdex.com ***

Author
27 May 2006 8:18 AM
Cor Ligthert [MVP]
Terry,

I had once some problems with the peek, while this one was working.

http://www.vb-tips.com/default.aspx?ID=1f8f3eaf-27a1-40d7-9e0b-23cab5aa1049

(be aware that we at the moment are very consequently refresing the site so
it can be a while not be there).

I hope this helps,

Cor

Show quoteHide quote
"Terry Olsen" <tolse***@hotmail.com> schreef in bericht
news:uwQfviQgGHA.4940@TK2MSFTNGP05.phx.gbl...
> I'm trying to use the CDBURN.EXE from the SDK. I start the process and
> redirect the output. I want to be able to get the output continuously so
> I can update the GUI. But it seems to "spit out" the StandardOutput only
> in large chunks. Here's my code... can someone give me some idea why
> it's doing this and if it can be fixed?
>
> Private Sub BurnCD(ByVal state As Object)
>        Dim args As String = state
>        Dim tmp As String = ""
>        Dim buf() As Char = {""}
>
>        BurnStartInfo.Arguments = args
>        BurnProcess.Start()
>        Dim sr As System.IO.StreamReader = BurnProcess.StandardOutput
>        While sr.Peek > 0
>            Try
>                sr.Read(buf, 0, 1)
>                tmp += buf(0)
>                Debug.WriteLine(tmp)
>            Catch ex As Exception
>                Debug.WriteLine(ex.Message)
>            End Try
>
>            If tmp.EndsWith(vbCrLf) = True Then
>                lblMsg.Text = tmp
>                tmp = ""
>            End If
>
>            If tmp.EndsWith("done") Then
>                lblProgress.Text = Val(tmp)
>                tmp = ""
>            End If
>        End While
>        sr.Close()
>        BurnProcess.WaitForExit()
>
>    End Sub
>
> *** Sent via Developersdex http://www.developersdex.com ***