473,418 Members | 3,795 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,418 software developers and data experts.

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(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim dt As Date
program.StartInfo.FileName = "Stage.exe"
program.StartInfo.Arguments = dt
program.StartInfo.WindowStyle = ProcessWindowStyle.hidden
program.StartInfo.UseShellExecute = False
program.StartInfo.RedirectStandardInput = True
program.StartInfo.RedirectStandardOutput = True
program.StartInfo.RedirectStandardError = True
program.Start()
srop = program.StandardOutput
sin = program.StandardInput
Dim oOutputThread As Thread = New Thread(AddressOf
ReadStdOut)
Dim oErrorThread As Thread = New Thread(AddressOf
ReadStdError)
With oOutputThread
.Name = "StandardOutput"
.Priority = ThreadPriority.Highest
.Start()
.Join()
End With

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

End Sub

Private Sub ReadStdOut()
srop = program.StandardOutput
sin = program.StandardInput
Dim sb As New System.Text.StringBuilder("")

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.StreamReader = program.StandardError
Dim sb As New System.Text.StringBuilder("")
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 1471

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

Similar topics

0
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...
2
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...
3
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...
15
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...
1
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...
4
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...
4
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...
2
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....
3
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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...

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.