On Mon, 15 Feb 2010, Joshua Lim wrote:


Hi,

I'm a pascal newbie, after spending some time getting a daemon to work, I now have 
trouble getting a timer to work.  I was recommended to use TFPTimer from the 
fpTimer unit - http://mantis.freepascal.org/view.php?id=14118&nbn=5

The standard driver for fpTimer is not suitable for use in a daemon
application, as the timer events are only triggered in the main thread,
and each daemon runs in its own thread.

Michael.

I tried the following code but the OnTimer doesn't trigger.  There are no 
errors either.  Grateful for any pointers.  :)

uses
fpTimer;
...
TDaemon1 = class(TDaemon)
....
private
.....
public
   procedure FTimerTimer( Sender : TObject );
.....
var
 Daemon1: TDaemon1;
 FTimer : TFPTimer;
.....
procedure TDaemon1.FTimerTimer( Sender : TObject );
var
...
BEGIN
....
END;

procedure TDaemon1.DataModuleStart(Sender: TCustomDaemon; var OK: boolean);
var
...
begin
FTimer := TFPTimer.Create(nil);
FTimer.OnTimer := @FTimerTimer;
FTimer.Interval := 1000; // in milliseconds
FTimer.Enabled := True;
FTimer.StartTimer;


Note: I've also posted here - 
http://lazarus.freepascal.org/index.php/topic,8615.0.html



_________________________________________________________________
Hotmail: Free, trusted and rich email service.
https://signup.live.com/signup.aspx?id=60969

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to