[DUG] TTimer

Rohit Gupta rohit at cfl.co.nz
Thu Jul 20 11:26:46 NZST 2006


John,

is the wakup code because the timer appears to freeze ?

I always have an IP (in progress) flag for timer event  thus

if IP
then Exit;

IP := True;
try
finally
  IP := False;
end;

This ensures that re-entrancy does not become a problem when what you 
execute inside takes longer then the next event.  While the VCL itself works 
ok, mult-form stuff does not.

From:           	"John Bird" <johnkbird at paradise.net.nz>
To:             	"'NZ Borland Developers Group - Delphi List'" <delphi at ns3.123.co.nz>
Subject:        	[DUG] TTimer
Date sent:      	Thu, 20 Jul 2006 11:10:41 +1200
Organization:   	John Bird Consulting
Send reply to:  	johnkbird at paradise.net.nz,
       	NZ Borland Developers Group - Delphi List <delphi at ns3.123.co.nz>
	<mailto:delphi-request at ns3.123.co.nz?subject=unsubscribe>
	<mailto:delphi-request at ns3.123.co.nz?subject=subscribe>

[ Double-click this line for list subscription options ] 

I have a couple of applications with a timer loop that is prone to
occasionally freezing after a few hours, not doing  anything radical, for
example displaying a date and time.

procedure TfrmJBCLMenu1.Timer1Timer(Sender: TObject);
begin

  lblToday.caption:=formatDateTime('dd mmm yy - hh:nn:ss',now);

end;


I noticed when the timer has stopped running that the rest of the
application runs ok, but seems also a bit sluggish, that is buttons respond
but slowly.

I put a bit of wake up code run when certain buttons are pressed like

//clock sometimes freezes...
procedure TfrmJBCLMenu1.WakeClock;
begin
  timer1.Enabled:=false;
  sleep(500);
  timer1.Enabled:=true;
end;

But I am thinking this shouldn't be needed!, and I am not sure it always
fixes it anyway.

Any suggestions to stop timers freezing?  Any known problems?

John

_______________________________________________
Delphi mailing list
Delphi at ns3.123.co.nz
http://ns3.123.co.nz/mailman/listinfo/delphi
Regards

Rohit

======================================================================
CFL - Computer Fanatics Ltd.  21 Barry's Point Road, AKL, New Zealand
PH    (649) 489-2280 
FX    (649) 489-2290
email rohit at cfl.co.nz  or  r.gupta at xtra.co.nz
======================================================================




More information about the Delphi mailing list