Recent

Author Topic: Timers as Threads  (Read 3395 times)

RegNatarajan

  • New Member
  • *
  • Posts: 28
Timers as Threads
« on: June 24, 2017, 03:30:50 am »
Do TTimers fire even if another timer's code is executing?  In other words, can I use a few timers to create what amounts to a multi-threaded application or do I need to figure out TThread?

HeavyUser

  • Sr. Member
  • ****
  • Posts: 397
Re: Timers as Threads
« Reply #1 on: June 24, 2017, 04:01:21 am »
Do TTimers fire even if another timer's code is executing? 
Lets be positive and say they do.
In other words, can I use a few timers to create what amounts to a multi-threaded application or do I need to figure out TThread?
The idea behind the timer is to inform the main application that the wait is over, even if they do post their message to the queue the main thread will need to finish processing all the previous message in the order fired before it gets to the one you might be interested in. So do they fire asynchronously? Probably. do you handle them asynchronously with out threads no.

RegNatarajan

  • New Member
  • *
  • Posts: 28
Re: Timers as Threads
« Reply #2 on: June 24, 2017, 05:03:03 am »
Thanks for that.  I was hoping for something easy but looks like I'll be digging into the help on TThread. Appreciate your help.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Timers as Threads
« Reply #3 on: June 24, 2017, 06:10:08 am »
Thanks for that.  I was hoping for something easy but looks like I'll be digging into the help on TThread. Appreciate your help.
there a couple of libraries to help with multithreading that you can use
1) mtprocs (do a search on the wiki it has a page) not very feature rich but as far as I can tell it helps.
2)PasMP (search github for it) it suppose to be a more "complete" (whatever that means) package.

I have not used any of them my self, so I don't really have an opinion to share, I prefer to write TThread classes my self, then again it might be that I got used to it before those libraries came to life.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

 

TinyPortal © 2005-2018