Recent

Author Topic: Timer thread separate from the main one  (Read 233 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2259
    • Lazarus and Free Pascal italian community
Timer thread separate from the main one
« on: September 16, 2025, 11:12:40 pm »
Hello everyone. I needed a timer that would run the code on a secondary thread and couldn't find a component to do it, so I wrote it myself. You can find the code here.

https://github.com/XinYiMan/threadtimer

You can also find an example in the example subfolder. I created it because I'm writing software to query a JSON server (written with the fpweb package). In the timer, I call the server to retrieve the JSON recordset (I compare the string hash with the hash retrieved in the previous read and saved in the State property. If the hashes are different, I trigger the OnAfterTimer event, which updates the values ​​in the form components). I'm open to suggestions for improving the component. For now, I've tested it on Windows and Linux Mint.
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

 

TinyPortal © 2005-2018