Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2006 Dec : Catch console output in real time
| Subject: | Catch console output in real time |
| Posted by: | "Thomas" (tomschneid..@trash-mail.de) |
| Date: | Fri, 8 Dec 2006 21:49:31 |
I need to catch the output of a command-line app (which is very busy and
sometimes may run up to 5 minutes) in *real* time with a Windows app.
The Win app is a form with a button and a memo. If you press the button a
thread will be created and executed. The thread starts a command-line app
(with CreateProcess) and reads the output of that app (via anonymous pipe /
redirected stdout) until the command-line app has finished. Each time the
thread gets an output line it sends that string to the main app using
PostMessage. The event handler of the main app outputs each string received
to the memo (with Memo.Lines.Add).
All steps described above work fine but it lasts nearly to *end* of
execution of the command-line app before there's any output displayed in the
main app's memo. I lowered the priority of the command-line process, I
inserted a short Sleep to the secondary thread, I tried Memo.Update, but
nothing changed that "non real time behaviour".
Any help would really appreciated.
Tom