Recent

Author Topic: Lazarus Timer for Clock  (Read 3245 times)

odvesims

  • Full Member
  • ***
  • Posts: 176
Lazarus Timer for Clock
« on: September 10, 2015, 05:24:24 pm »
Hello There!

In my project, after login process is completed, the server sends me a string containing its current time (sometimes off by a few seconds if the connection lags). After i receive it, I use it as the initial time for a clock i update every second using a Timer.

However, whenever the GUI is blocked/halted, the timer "ticking" procedure also stops. I have an idea that maybe i need to run the timer in a different thread, but i have no clue on how to properly implement it.

Any help?

Oscar

derek.john.evans

  • Guest
Re: Lazarus Timer for Clock
« Reply #1 on: September 10, 2015, 05:35:41 pm »
Would storing the delta value between the client system time and the server time work?

Then you can get the server time using something like: Now + FServerDelta

Graeme

  • Hero Member
  • *****
  • Posts: 1469
    • Graeme on the web
Re: Lazarus Timer for Clock
« Reply #2 on: September 10, 2015, 05:37:05 pm »
I don't think using a thread is going to solve you problem, but if you want to, FPC includes a thread based timer in the fptimer unit.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Lazarus Timer for Clock
« Reply #3 on: September 11, 2015, 12:51:06 am »
TTimer doesn't stop when for example ShowMessage() or TOpenDialog is opened.

shobits1

  • Sr. Member
  • ****
  • Posts: 271
  • .
Re: Lazarus Timer for Clock
« Reply #4 on: September 11, 2015, 07:18:16 am »
like `Geepster` suggested, implementing a delta value operation between local and server time is the best and simplifies the program a lot.
« Last Edit: September 11, 2015, 07:23:26 am by shobits1 »

 

TinyPortal © 2005-2018