[fpc-pascal] TFileStream and stdin - how to make this work?
Honza
befelemepeseveze at gmail.com
Sun Oct 3 16:16:51 CEST 2010
2010/10/3 Bernd Kreuss <prof7bit at googlemail.com>:
> TIOStream seems to work the same way on linux and windows (I tested only
> with wine but it worked) ...and it will block.
>
> It seems I really have to do the receiving of the data in a separate
> thread.
>
> (I wanted to avoid this because the things that must be done after
> reading the data must be done in the main thread (it's a GUI
> application) and now I have to fiddle around with synchronize & friends
> instead of a simple method call which is not nice because I also have to
> immediately answer the messages on stdout in a synchronous manner with
> information received from the GUI. Polling on idle from the GUI thread
> would have been so much more simple and elegant.)
See also sockets:
http://wiki.lazarus.freepascal.org/Sockets
and pipes:
http://www.freepascal.org/docs-html/fcl/pipes/tinputpipestream.html
The TInputPipeStream has a "property NumBytesAvailable: DWord; [r]
Number of bytes available for reading.", which may enable the polling.
--
bflm
freepascal-bits.blogspot.com
More information about the fpc-pascal
mailing list