473,386 Members | 1,720 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,386 software developers and data experts.

Process.RedirectStandardOutput problem

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 ***
May 26 '06 #1
1 1528
Terry,

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

http://www.vb-tips.com/default.aspx?...b-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

"Terry Olsen" <to******@hotmail.com> schreef in bericht
news:uw**************@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 ***

May 27 '06 #2

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

Similar topics

5
by: ask | last post by:
Hi NG I'm a bit new to programming c# and have a question regarding ftp by the command prompt. As far as I can see it should be possible to start a process and pipe command streams into it. But...
4
by: jam | last post by:
Dear All, I have a command process running xcopy in console, and now I want to execute the program Rsync After the files are copied...how could i do?? Process p10=new Process();...
3
by: James Li | last post by:
I have the code below, the first process takes about 10 minutes to finish. But the waitForExit doesn't seem to wait when I debug the program, it go immediately to execute code after the...
6
by: danl | last post by:
I need to be able to execute a .bat file from a C# web application I have the following code that compliles and seems to run fine, but the bat file never does it's work...
7
by: DraguVaso | last post by:
Hi, I want my application to Start another application. I do it like this: Dim prcSiclid As New Process prcSiclid.StartInfo.UseShellExecute = True prcSiclid.StartInfo.RedirectStandardOutput =...
15
by: jcrouse | last post by:
Here is my code: Dim sw As StreamWriter = File.CreateText(Application.StartupPath & "\mameversion.bat") sw.WriteLine(lblMameExePath.Text & " -help >""" & Application.StartupPath &...
7
by: WALDO | last post by:
I wrote a console application that basically consumes arguments and starts other command line apps via System.Process. Let's call it XCompile for now. I wrote a Visual basic add-in that does pretty...
11
by: Nurit N | last post by:
This is the third newsgroup that I'm posting my problem. I'm sorry for the multiple posts but the matter becoming urgent. I hope this is the right place for it... I have created a very...
5
by: =?Utf-8?B?Z215ZXJz?= | last post by:
Hello, I am attempting to start a cmd.exe process and pass several .vbs scripts (with additional parameters) and then read the output from the scripts and make "notes" in a DataTable (the...
11
by: Jon Davis | last post by:
Does anyone know why using System.Diagnostics.Process to "wrap" a console application does not always transmit the I/O, depending on what processes you're trying to "consume"? PowerShell, for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.