Click here to Skip to main content
15,903,203 members
Home / Discussions / C#
   

C#

 
AnswerRe: getting a specific tag out of a web page Dom info Pin
manustone12-Jan-10 20:41
manustone12-Jan-10 20:41 
QuestionMerge strings and overwrite certain characters based on a filter Pin
AndreasLa11-Jan-10 6:18
AndreasLa11-Jan-10 6:18 
AnswerRe: Merge strings and overwrite certain characters based on a filter Pin
Dave Kreskowiak11-Jan-10 6:32
mveDave Kreskowiak11-Jan-10 6:32 
AnswerRe: Merge strings and overwrite certain characters based on a filter Pin
Saksida Bojan11-Jan-10 6:38
Saksida Bojan11-Jan-10 6:38 
Questionwriting xml using datagrid Pin
naghoumeh1411-Jan-10 6:04
naghoumeh1411-Jan-10 6:04 
QuestionGetting all data from commandline app Pin
blaatschapje11-Jan-10 5:31
blaatschapje11-Jan-10 5:31 
AnswerRe: Getting all data from commandline app Pin
Alan N11-Jan-10 6:22
Alan N11-Jan-10 6:22 
AnswerRe: Getting all data from commandline app Pin
Luc Pattyn11-Jan-10 7:01
sitebuilderLuc Pattyn11-Jan-10 7:01 
You're trying to get the console output generated by an app. There typically can be two output streams, one is the (regular) output stream (stdout in C environment), the other the error stream (stderr in C environment). The former typically is used for regular output, the latter for error reporting (but you can't really tell just by looking at it).

You can easily get both of them asynchronously (i.e. after the process has finished) by using Process.StandardOutput.ReadToEnd() and Process.StandardError.ReadToEnd().

If you want to get them both while the process is still running, you need more than one thread, as the read calls (like the ReadLine you're using now) are blocking. There are two ways to get there:
1. use 2 threads, each having a loop such as yours;
2. use 2 events: Process.OutputDataReceived and Process.ErrorDataReceived which probably run on ThreadPool threads automatically (cfr this article[^])

wathever choice you make, be careful about thread safety (in a WinForms app your threads or event handlers would not be allowed to touch GUI Controls directly (for more, see rhis article[^])

Smile | :)

Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

Happy New Year to all.
We hope 2010 soon brings us automatic PRE tags!
Until then, please insert them manually.


QuestionMerging or adding 2 different DataTables into Single DataTable Pin
K V Sekhar11-Jan-10 5:20
K V Sekhar11-Jan-10 5:20 
AnswerRe: Merging or adding 2 different DataTables into Single DataTable Pin
Dave Kreskowiak11-Jan-10 6:26
mveDave Kreskowiak11-Jan-10 6:26 
GeneralRe: Merging or adding 2 different DataTables into Single DataTable Pin
K V Sekhar11-Jan-10 15:39
K V Sekhar11-Jan-10 15:39 
GeneralRe: Merging or adding 2 different DataTables into Single DataTable Pin
Dave Kreskowiak11-Jan-10 17:29
mveDave Kreskowiak11-Jan-10 17:29 
QuestionBlocking Queue Pin
ika211-Jan-10 3:38
ika211-Jan-10 3:38 
AnswerRe: Blocking Queue Pin
harold aptroot11-Jan-10 3:41
harold aptroot11-Jan-10 3:41 
GeneralRe: Blocking Queue Pin
ika211-Jan-10 4:18
ika211-Jan-10 4:18 
GeneralRe: Blocking Queue [modified] Pin
harold aptroot11-Jan-10 4:32
harold aptroot11-Jan-10 4:32 
AnswerRe: Blocking Queue Pin
Nicholas Butler11-Jan-10 5:31
sitebuilderNicholas Butler11-Jan-10 5:31 
QuestionProblem at second connection attempt Pin
sleepyman11-Jan-10 3:29
sleepyman11-Jan-10 3:29 
AnswerRe: Problem at second connection attempt Pin
OriginalGriff11-Jan-10 4:06
mveOriginalGriff11-Jan-10 4:06 
GeneralRe: Problem at second connection attempt Pin
sleepyman11-Jan-10 4:15
sleepyman11-Jan-10 4:15 
GeneralRe: Problem at second connection attempt Pin
OriginalGriff11-Jan-10 4:37
mveOriginalGriff11-Jan-10 4:37 
GeneralRe: Problem at second connection attempt Pin
sleepyman11-Jan-10 5:57
sleepyman11-Jan-10 5:57 
GeneralRe: Problem at second connection attempt Pin
OriginalGriff11-Jan-10 8:19
mveOriginalGriff11-Jan-10 8:19 
QuestionRead in Cyrillic, Arabic, Japanese with GetWindowText not working Pin
elmernite11-Jan-10 3:04
elmernite11-Jan-10 3:04 
AnswerMessage Closed Pin
11-Jan-10 3:14
stancrm11-Jan-10 3:14 

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.