Click here to Skip to main content
15,895,256 members
Home / Discussions / C#
   

C#

 
GeneralGDI+ Dashed line Pin
gadgetfbi29-Sep-03 7:35
gadgetfbi29-Sep-03 7:35 
GeneralRe: GDI+ Dashed line Pin
Heath Stewart29-Sep-03 9:04
protectorHeath Stewart29-Sep-03 9:04 
GeneralRe: GDI+ Dashed line Pin
Daniel M. Edwards29-Sep-03 10:25
Daniel M. Edwards29-Sep-03 10:25 
GeneralRe: GDI+ Dashed line Pin
gadgetfbi29-Sep-03 12:16
gadgetfbi29-Sep-03 12:16 
GeneralJPEG2000 Pin
gicio29-Sep-03 7:02
gicio29-Sep-03 7:02 
GeneralImport CSV File to MS Access Pin
raysot29-Sep-03 6:21
raysot29-Sep-03 6:21 
GeneralRe: Import CSV File to MS Access Pin
Steve McLenithan29-Sep-03 7:29
Steve McLenithan29-Sep-03 7:29 
GeneralReading StandardOutput Pin
Wjousts29-Sep-03 4:57
Wjousts29-Sep-03 4:57 
I'm trying to read the StandardOutput of a process while it is running, but I'm unable to read anything from the StandardOutput before the process actually finishes. Here's what I currently have. I was trying to multithread it in the hope that that would solve the problem but it still doesn't, although it doesn't hang up my whole application anymore Smile | :) The method PutFiles is called first:

<br />
		public void PutFiles(string FilePath)<br />
		{<br />
			string args = "-r -pw " + m_Password + " " + FilePath + " " + m_UserID + "@" + m_Address + ":" + m_CalcPath;<br />
			m_ProcessArgs = args;<br />
			m_ProcessApp = "pscp.exe";<br />
			Thread myThread = new Thread(new ThreadStart(TransferProcess));<br />
			myThread.Start();<br />
		}<br />
<br />
		private void TransferProcess()<br />
		{<br />
			ProcessStartInfo pInfo = new ProcessStartInfo(m_ProcessApp,m_ProcessArgs);<br />
			pInfo.UseShellExecute = false;<br />
			pInfo.RedirectStandardOutput = true;<br />
			pInfo.RedirectStandardError = true;<br />
			pInfo.CreateNoWindow = true;<br />
			m_Running = Process.Start(pInfo);<br />
			m_StdOut = m_Running.StandardOutput;<br />
			Thread InfoThread = new Thread(new ThreadStart(ProcessInfo));<br />
			InfoThread.Start();<br />
			m_Running.WaitForExit();<br />
			MessageBox.Show("Transfer Thread Done");<br />
		}<br />
<br />
		private void ProcessInfo()<br />
		{<br />
			MessageBox.Show(m_StdOut.Read().ToString());<br />
		}<br />


The MessageBox in the ProcessInfo thread will not be displayed until the process is actually finished. If I don't try reading the stream in the ProcessInfo method then it'll display a textbox immediately. I've tried Read, ReadLine and ReadToEnd, but they all do the same thing. What I'm trying to do is grab the StandardOutput while it is being produced so that I can echo it to the user and they'd know whats going on.
Anybody got any ideas on this one?
GeneralRe: Reading StandardOutput Pin
Heath Stewart29-Sep-03 9:09
protectorHeath Stewart29-Sep-03 9:09 
GeneralRe: Reading StandardOutput Pin
Wjousts29-Sep-03 10:25
Wjousts29-Sep-03 10:25 
GeneralRe: Reading StandardOutput Pin
Heath Stewart30-Sep-03 1:20
protectorHeath Stewart30-Sep-03 1:20 
GeneralRe: Reading StandardOutput Pin
Wjousts30-Sep-03 4:06
Wjousts30-Sep-03 4:06 
GeneralUrgent Help needed Pin
GenieUk29-Sep-03 4:02
GenieUk29-Sep-03 4:02 
GeneralValidating pasted text in textbox Pin
ecopilot29-Sep-03 4:01
ecopilot29-Sep-03 4:01 
GeneralRe: Validating pasted text in textbox Pin
Wjousts29-Sep-03 4:48
Wjousts29-Sep-03 4:48 
Generalhandling internet explorer events from a console application in VS.net Pin
Sonja-Hartmann29-Sep-03 3:29
Sonja-Hartmann29-Sep-03 3:29 
Questionhow to make a shortcut in .net cf Pin
tignatov29-Sep-03 0:21
tignatov29-Sep-03 0:21 
Generalpass parameter to a method in new thread Pin
zecodela28-Sep-03 23:11
zecodela28-Sep-03 23:11 
GeneralRe: pass parameter to a method in new thread Pin
Corinna John29-Sep-03 2:26
Corinna John29-Sep-03 2:26 
QuestionScrolling two textboxes with one scrollbar??? Pin
Steppen Wolf28-Sep-03 21:07
sussSteppen Wolf28-Sep-03 21:07 
AnswerRe: Scrolling two textboxes with one scrollbar??? Pin
Anonymous29-Sep-03 1:18
Anonymous29-Sep-03 1:18 
GeneralRe: Scrolling two textboxes with one scrollbar??? Pin
Steppen_Wolf29-Sep-03 5:33
sussSteppen_Wolf29-Sep-03 5:33 
GeneralAdding a Class Library Pin
gmhanna28-Sep-03 8:32
gmhanna28-Sep-03 8:32 
GeneralRe: Adding a Class Library Pin
Daniel M. Edwards28-Sep-03 9:27
Daniel M. Edwards28-Sep-03 9:27 
GeneralRe: Adding a Class Library Pin
gmhanna28-Sep-03 10:08
gmhanna28-Sep-03 10:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.