Process.RedirectStandardOutput problem

T

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top