Click here to Skip to main content
15,905,967 members
Home / Discussions / C#
   

C#

 
QuestionRe: modify XmlDictionaryReaderQuotas Pin
abbd26-Dec-10 7:30
abbd26-Dec-10 7:30 
AnswerRe: modify XmlDictionaryReaderQuotas Pin
Keith Barrow26-Dec-10 7:59
professionalKeith Barrow26-Dec-10 7:59 
QuestionRe: modify XmlDictionaryReaderQuotas Pin
abbd26-Dec-10 8:04
abbd26-Dec-10 8:04 
QuestionRe: modify XmlDictionaryReaderQuotas Pin
abbd26-Dec-10 23:18
abbd26-Dec-10 23:18 
QuestionRedirecting standard output of an application Pin
TcachTcachTcach25-Dec-10 21:36
TcachTcachTcach25-Dec-10 21:36 
AnswerRe: Redirecting standard output of an application Pin
Abhinav S25-Dec-10 23:18
Abhinav S25-Dec-10 23:18 
GeneralRe: Redirecting standard output of an application Pin
TcachTcachTcach26-Dec-10 0:26
TcachTcachTcach26-Dec-10 0:26 
AnswerRe: Redirecting standard output of an application Pin
Luc Pattyn26-Dec-10 1:57
sitebuilderLuc Pattyn26-Dec-10 1:57 
I'm not sure, but here is my best guess:

it is all about the definition of "new line".

On Windows systems, a native C/C++ program creates a "new line" by outputting a \n which basically is the ASCII linefeed; Windows however by default wants a carriagereturn+linefeed, therefore most run-times will expand \n to \n\r automatically.

Again on Windows systems, a managed code program uses \n\r as newline string, see Environment.NewLine (Note: Mono on Unix would simply use \n here).
For serial ports, the user can set a different newline string, see SerialPort.NewLine
For streams, like you are using, there is no such facility.

Now my guess is that your C program, writing to a stream rather than a real output device (such as the console), doesn't get itsn expanded to \n\r, which your managed code is looking for; therefore the output is not multi-line, and only gets captured when the producer terminates.

If all the above applies, then these are some solutions:

1.
replace every \n by \n\r in your producer (C code)

2.
or stop using all the line-oriented stuff (the DataReceived handlers and the ReadLine method) in your consumer; instead use a thread with a loop, and read arbitrary strings. Note: two threads would be required if you wanted to deal with real-time stdout and stderr.


FWIW: the situation may get more complicated when you are on a virtual system; I have been told Citrix for example does not handle interprocess streams properly (although it might have been a \n versus \n\r issue there too).

Smile | :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Season's Greetings to all CPians.


modified on Sunday, December 26, 2010 10:49 AM

GeneralRe: Redirecting standard output of an application Pin
TcachTcachTcach26-Dec-10 2:32
TcachTcachTcach26-Dec-10 2:32 
AnswerRe: Redirecting standard output of an application Pin
Luc Pattyn26-Dec-10 3:02
sitebuilderLuc Pattyn26-Dec-10 3:02 
GeneralRe: Redirecting standard output of an application Pin
TcachTcachTcach26-Dec-10 3:47
TcachTcachTcach26-Dec-10 3:47 
GeneralRe: Redirecting standard output of an application Pin
Luc Pattyn26-Dec-10 3:55
sitebuilderLuc Pattyn26-Dec-10 3:55 
AnswerRe: Redirecting standard output of an application Pin
PIEBALDconsult26-Dec-10 4:56
mvePIEBALDconsult26-Dec-10 4:56 
GeneralRe: Redirecting standard output of an application Pin
TcachTcachTcach27-Dec-10 23:12
TcachTcachTcach27-Dec-10 23:12 
QuestionWeak reference and garbage collection Pin
thomus0724-Dec-10 22:24
thomus0724-Dec-10 22:24 
AnswerRe: Weak reference and garbage collection Pin
#realJSOP25-Dec-10 0:35
professional#realJSOP25-Dec-10 0:35 
AnswerRe: Weak reference and garbage collection Pin
SledgeHammer0125-Dec-10 7:27
SledgeHammer0125-Dec-10 7:27 
GeneralRe: Weak reference and garbage collection Pin
thomus0725-Dec-10 19:03
thomus0725-Dec-10 19:03 
AnswerRe: Weak reference and garbage collection Pin
Pete O'Hanlon25-Dec-10 8:41
mvePete O'Hanlon25-Dec-10 8:41 
GeneralRe: Weak reference and garbage collection Pin
thomus0725-Dec-10 19:06
thomus0725-Dec-10 19:06 
AnswerRe: Weak reference and garbage collection Pin
_Erik_27-Dec-10 2:46
_Erik_27-Dec-10 2:46 
AnswerRe: Weak reference and garbage collection Pin
jschell27-Dec-10 8:12
jschell27-Dec-10 8:12 
QuestionAnswer this question Pin
mohammed alshaweesh24-Dec-10 4:23
mohammed alshaweesh24-Dec-10 4:23 
JokeRe: Answer this question PinPopular
PIEBALDconsult24-Dec-10 4:31
mvePIEBALDconsult24-Dec-10 4:31 
GeneralRe: Answer this question Pin
OriginalGriff24-Dec-10 4:45
mveOriginalGriff24-Dec-10 4:45 

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.