[fpc-pascal] *** SPAM *** Re: USB Human Interface Devices

James Richters james at productionautomation.net
Fri Aug 16 20:41:03 CEST 2019


Thanks for the link to the tutorial,  I'll have to look into that!   I have kind of a mess of things that runs through this whole sequential list checking all these different timings to see what needs to be done.. if all the things that required different timings were each in their own thread it would simplify things greatly

James

-----Original Message-----
From: fpc-pascal <fpc-pascal-bounces at lists.freepascal.org> On Behalf Of Jean SUZINEAU
Sent: Friday, August 16, 2019 1:34 PM
To: fpc-pascal at lists.freepascal.org
Subject: Re: [fpc-pascal] *** SPAM *** Re: USB Human Interface Devices

Le 16/08/2019 à 17:11, James Richters a écrit :
> Can I even do threads in a console program?

Yes, you can.  I have in production some console code (worse: in a dll called by a console program written in 4gl (4js Genero www.4js.com)) with threads which compile unmodified  under Linux and Windows.

By writing a descendant of TThread it's relatively easy to write a thread in FreePascal ( https://wiki.freepascal.org/Multithreaded_Application_Tutorial ).
 From your (non main) thread you can execute a procedure in the main thread by calling TThread.Synchronize.

 From what I remember, the main problem in console is that you need to call regularly CheckSynchronize() ( from unit Classes ) from your program which run the main thread.
That will be simpler for you, in my case, I had  to export from my dll a pascal function calling CheckSynchronize() and call it regularly from the 4gl program with a timer ...

As far as I remember, it works just with a queue, when you call Synchronize you add a function call to the queue, and CheckSynchronize() read the queue and do the actual call of your function.





_______________________________________________
fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


More information about the fpc-pascal mailing list