Bo Berglund wrote:

My most recent investigation is about how to create a TCPIP socket
object that has event driven receive functions. I have no use for the
problem unit in that quest so this thread is not really valid for
those problems. Last I tested Indy10 with the help of Remy Lebeau but
in the end I got caught by my inability to use a blocking socket with
threads and fire off events into the main code running as the command
line program.

What does the main thread do? If you can contrive to write that as a loop, then as you've already been told you can call CheckSynchronize() which hands control to whatever's been queued by threads using Synchronize().

Depending on exactly what the program does, you might need to do something like fudging keyboard access using fpSelect(), but basically it works... I've got a mainframe emulator here which responds to keyboard commands and also interleaves output from the various backend processes, I've used Lazarus as the IDE but it's entirely a console app.

I cannot use Synchronize because then the events fire off only when
the main program code ends and if I don't use Synchronize then I get a
SIGSEG exception somewhere.

Assume that none of the LCL is thread-safe, i.e. background threads have no safe UI access. Assume that the RTL and FCL are not specifically thread safe except where documented, but that you can use it in conjunction with conventional "cautious" programming techniques.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to