[fpc-pascal] Cannot get TFPTimer to work
Brian Winfrey
bwcode4u at gmail.com
Thu Dec 2 21:06:36 CET 2010
See .../fpcsrc/packages/fcl-base/examples/testtimer.pp for example usage.
On Thu, Dec 2, 2010 at 10:39 AM, Darius Blaszyk
<dhkblaszyk at zeelandnet.nl> wrote:
> Whatever I tried, I cannot get TFPTimer to work. Can someone help? For
> some reason the OnTimer even is never fired. Tried on Windows and Linux.
> Here's a snippet I used as test.
>
> Regards, Darius
>
>
>
> program fptimertest;
>
> {$mode objfpc}{$H+}
>
> uses
> {$IFDEF UNIX}
> cthreads,
> {$ENDIF}
> SysUtils, fpTimer;
>
> type
>
> { TBaseObj }
>
> TBaseObj = class(TObject)
> tmr: TFPTimer;
> public
> constructor Create;
> constructor Destroy;
> procedure OnTimerExec(Sender: TObject);
> end;
>
> { TBaseObj }
>
> constructor TBaseObj.Create;
> begin
> tmr := TFPTimer.Create(nil);
> tmr.Interval := 1;
> tmr.OnTimer:=@OnTimerExec;
> tmr.StartTimer;
> end;
>
> constructor TBaseObj.Destroy;
> begin
> tmr.StopTimer;
> tmr.Free;
> end;
>
> procedure TBaseObj.OnTimerExec(Sender: TObject);
> begin
> writeln('Timer executed');
> end;
>
> var
> test: TBaseObj;
> i: integer;
>
> begin
> test := TBaseObj.Create;
> for i := 1 to 1000 do
> sleep(10);
>
> writeln('done');
> readln;
> end.
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
More information about the fpc-pascal
mailing list