See .../fpcsrc/packages/fcl-base/examples/testtimer.pp for example usage.

On Thu, Dec 2, 2010 at 10:39 AM, Darius Blaszyk
<dhkblas...@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-pas...@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to