[fpc-pascal] Console application with multi-threading

Marco van de Voort marcov at stack.nl
Mon May 4 13:40:16 CEST 2009


In our previous episode, Graeme Geldenhuys said:
> 
> Is it possible to have a multi-threaded console application?  For
> example I have a console application that does logging to a file. The
> file logging is handled in a thread that does caching and contention
> handling. This works fine for GUI based applications, but what about
> Console based applications?

It works fine also.

> The reason I ask, is because I can't see CheckSynchronize() being
> called anywhere in TCustomApplication descendants like what Lazarus
> (console app project) creates?

Synchronization is an additional feature, not basic thread support. It can
also be in a console app, but afaik then the application must be event
driven (return regularly to some main loop). Like e.g. the textmode IDE
(though it does not _USE_ threading)

In such mainloop checksynchronize should be called.

> So how does this work with TThread based threads and console apps?




More information about the fpc-pascal mailing list