Using events in console programs

Please discuss general Delphi programming topics here.

Using events in console programs

Postby werdnareid » August 16th, 2003, 2:31 pm

How can i use a type "TTimer" even "onTimer" in console program?

TIA:
werdnareid
Active Member
Active Member
 
Posts: 22
Joined: August 6th, 2003, 5:35 pm

Postby Kambiz » August 16th, 2003, 5:19 pm

You cannot, because TTimer uses a Window message queue to get the timer events. Try to use a threaded timer instead of TTimer.

You can find a freeware threaded timer at http://www.delphipages.com/result.cfm?ID=2277.
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby Johnny_Bit » August 17th, 2003, 7:38 pm

Well.. I think You can use TTimer, but you have to create it Dynamicly (at runtime).
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am

Postby Johnny_Bit » August 25th, 2003, 3:11 pm

If it's hard to use it OnTimerEvent then:

Code: Select all
type TTimerEventos=class
procedure OnTimerTimer(Sender: TObject);

in implementation:

TTimerEventos.OnTimeTimer(Sender: TObject);
begin
//do whatever you like
end;

in procedure that creates timer (for sample called DynaTimer):

{Code that creates timer and sets it's all properties}
DynaTimer.OnTimer:=TTimerEventos.OnTimerTimer;
{rest of code}


I hope you understand...
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron