473,606 Members | 3,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Could not get the standardoutput from the process simultaneously when the process is executing.

I am running an executable from my aspx page with the click of a
button. A date is passed as an argument. I am able to get the
standardoutput from the Process(Exe) into the label of my page after
the process has completed executing. My problem is I need to get the
output in the label simultaneously when the EXE is running, not after
it has completed executing. Just like when I run the Exe in the cmd
prompt. In my code I am opening two threads for standardoutput and
StandardError. All the standardoutput is being buffered in a
stringbuilder and then being displayed in the label. Is there any
command that I can display the standard ouput in a label after reading
a line from the string builder? Is this the correct way to approach?
Any help is appreciated. Below is my code.

Public Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click

Dim dt As Date
program.StartIn fo.FileName = "Stage.exe"
program.StartIn fo.Arguments = dt
program.StartIn fo.WindowStyle = ProcessWindowSt yle.hidden
program.StartIn fo.UseShellExec ute = False
program.StartIn fo.RedirectStan dardInput = True
program.StartIn fo.RedirectStan dardOutput = True
program.StartIn fo.RedirectStan dardError = True
program.Start()
srop = program.Standar dOutput
sin = program.Standar dInput
Dim oOutputThread As Thread = New Thread(AddressO f
ReadStdOut)
Dim oErrorThread As Thread = New Thread(AddressO f
ReadStdError)
With oOutputThread
.Name = "StandardOutput "
.Priority = ThreadPriority. Highest
.Start()
.Join()
End With

With oErrorThread
.Name = "StandardEr ror"
.Priority = ThreadPriority. Normal
.Start()
.Join()
End With

End Sub

Private Sub ReadStdOut()
srop = program.Standar dOutput
sin = program.Standar dInput
Dim sb As New System.Text.Str ingBuilder("")

Dim input As String = srop.Read
Do Until input = -1
If input = 13 Then
sb.Append("<br> ")
End If
sb.Append(ChrW( input))
input = srop.Read
Loop
Label1.Text += sb.ToString
End Sub

Private Sub ReadStdError()

Dim str As System.IO.Strea mReader = program.Standar dError
Dim sb As New System.Text.Str ingBuilder("")
Dim input As Integer = str.Read
Do Until input = -1
If input = 13 Then
sb.Append("<br> ")
End If
sb.Append(ChrW( input))
input = str.Read
Loop
Label1.Text += sb.ToString
End Sub

Thanks,
Atluri.

Nov 21 '05 #1
0 1485

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

Similar topics

0
412
by: John Lewin | last post by:
I've recently discovered the value of using existing console applications in managed .net apps. Unfortunately, I've stumbled into a problem with a particular console application that check's crc info on CDs. Using either the StandardError or StandardOutput streams read, readline or peek methods causes an immediate block that doesn't release until the console app finishes it's business. I want to launch this console app and update my UI to...
2
2256
by: mwazir | last post by:
Hi all, I have reposted this question from dotnet.general as I have been advised that this is a more appropriate forum for this question. Apologies for the repost. I have a process thats starts in my application and only terminates when my application is terminated. I want to write the output and the errors of this process to a seperate log file. In order to do this, I spawned two threads.
3
10389
by: Al Cohen | last post by:
I'll start by warning that I'm a newbie to C# (but I've been programming for 25 years), so I may just be doing something reallyreally dumb. I'm writing a C# wrapper for a command-line application (pscp.exe, a secure file-copy app that's part of the excellent PuTTY SSH package). Getting pscp.exe to run properly was a piece of cake using the System.Diagnostics.Process class. The thing that I can't get to work is the ability to read...
15
3095
by: Matt Burland | last post by:
I'm having a problem with redirecting the StandardOutput of a process that I use to run a DOS program in my application. The problem is that I when I start my process (which I do in a separate thread) I can't read anything from the stdout before the process actually finishes. If I do something like this: Process myProcess = new Process(myStartInfo) // this gets shown straight away MessageBox.Show("Process Started"); string s =...
1
8850
by: JC | last post by:
I'm trying to create a GUI wrapper for dumpbin, and so I'm using the Process class to run the command-line application. The problem is that if I use Readline() to get the output from the commandline app, it will hang when it comes to the command-prompt (there's no return to send it to readline). Here's the code: public bool RunCommands(string cmds, ArrayList files) {
4
13123
by: Steve | last post by:
I am using Diagnostics.Process to, well.. execute a process. I would like to display the output of the process to my UI as it is created. For example, ping www.yahoo.com will slowly output each result. I want to display that output as it happens in my UI. I don't see a clean way to do this. After my Start() call, I made a call to StandardOutput.ReadToEnd() but it appears to hang until the process finishes (makes sense) But what do...
4
3605
by: Eric ST | last post by:
Hi there, I run a process that run ftp.exe -s i get the StandardOutput this way : ftpProgram = Process.Start(ftpProgram.StartInfo) Output = ftpProgram.StandardOutput.ReadToEnd ftpProgram.WaitForExit() From my computer i get the output ok :
2
2273
by: mwazir | last post by:
Hi all, I have a process thats starts in my application and only terminates when my application is terminated. I want to write the output and the errors of this process to a seperate log file. In order to do this, I spawned two threads. My code looks something like this ' Starting the process oProcessStartInfo = New ProcessStartInfo()
3
1414
by: Clutch152 | last post by:
First off, hello everyone. This site has helped me find answeres to numberous questions. What I want to make is a kill tracker for Wolfenstein enemy territory and I want the program to find kills and deaths in the game by reading from the console. W:ET is a quake 3 based game and I am not positive that this is the correct method for this but it would still be good to know in the future. I want the program to find the game when and if it...
0
7978
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8461
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8448
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6796
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5987
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5470
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4010
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2454
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1313
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.