Recent

Author Topic: TTimer Interval confusion  (Read 3527 times)

simsam

  • Newbie
  • Posts: 3
TTimer Interval confusion
« on: March 19, 2013, 01:46:57 pm »
Hello,

I have an issue with TTimer.

I placed three timers on the androidlcl form and each of these timers simply increases a counter and writes the result to a label:

Timer1.Interval = 500
Timer2.Interval = 1000
Timer3.Interval = 2000

procedure TForm1.Timer1Timer(Sender : TObject)
begin
  Inc(counter1);
  Label1.Caption := IntToStr(counter1);
end;

procedure TForm1.Timer2Timer(Sender : TObject)
begin
  Inc(counter2);
  Label2.Caption := IntToStr(counter2);
end;

procedure TForm1.Timer3Timer(Sender : TObject)
begin
  Inc(counter3);
  Label3.Caption := IntToStr(counter3);
end;

The result of all of this is that all the counters increase at the same rate of around 500ms.
LogCat tells me that all the timers have been created with their respective interval.
Anyone having this same issue? In my app I worked around it by having only one timer running a base cycle and doing the timing stuff from there. But that's not cool.
« Last Edit: March 19, 2013, 01:57:12 pm by simsam »

jhmos

  • New Member
  • *
  • Posts: 24
Re: TTimer Interval confusion
« Reply #1 on: March 19, 2013, 03:21:09 pm »
In my app I worked around it by having only one timer running a base cycle and doing the timing stuff from there.

Unfortunately, thats what you have to do. Works the same under MS windows. I vaguely recall when I looked at this problem, that the only way to have multiple timers is to use multiple threads (with all that added complexity).

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: TTimer Interval confusion
« Reply #2 on: March 19, 2013, 03:58:32 pm »
The result of all of this is that all the counters increase at the same rate of around 500ms.

That is clearly a bug in LCL+Android. Please file a bug report in Mantis (http://bugs.freepascal.org/my_view_page.php).
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: TTimer Interval confusion
« Reply #3 on: March 19, 2013, 06:51:08 pm »
Works the same under MS windows. I vaguely recall when I looked at this problem, that the only way to have multiple timers is to use multiple threads (with all that added complexity).
No, i just tried this on Lazarus 1.1 on Win32 and 3 labels are growing number at different paces, depending on interval.

 

TinyPortal © 2005-2018