, , , - , . , , ( 500 , 1 60 000 120 , ). , .
( ), /. : , . , . , ...
uses
DateUtils;
.....
var
HasExecuted: Bool;
.....
constructor TForm1.Create(Sender: TObject);
begin
HasExecuted:= False;
end;
procedure TimerOnTimer(Sender: TObject);
var
N, A: TDateTime;
Thread: TMyThread;
begin
N := Now;
A := StrToDateTime('11/20/2011 15:30:30'); //24 hour time
//If now is within 1 second over/under alarm time...
if (N >= IncSecond(A, -1)) and (N <= IncSecond(A, 1)) then
begin
if not HasExecuted then begin
HasExecuted:= True;
aThread := tMyThread.Create(true);
aThread.Resume; //The thread will execute once and terminate;
end;
end;
end;
, , =. , 1 ? , , true.
, TMyThread - ? , False CreateSuspended? , , . True , , , Thread.Resume (, , ). , ( , ), . , ? ( , , , ). , , , , ...
constructor TMyThread.Create(CreateSuspended: Bool);
begin
inherited Create(CreateSuspended);
FreeOnTerminate:= True; //Make sure it free its self when it terminated
end;
EDIT:
- - , , 1 ( 200-400), , . , , . . , delphi.