Page 1 of 1

Using events in console programs

PostPosted: August 16th, 2003, 2:31 pm
by werdnareid
How can i use a type "TTimer" even "onTimer" in console program?

TIA:

PostPosted: August 16th, 2003, 5:19 pm
by Kambiz
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.

PostPosted: August 17th, 2003, 7:38 pm
by Johnny_Bit
Well.. I think You can use TTimer, but you have to create it Dynamicly (at runtime).

PostPosted: August 25th, 2003, 3:11 pm
by Johnny_Bit
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...