考慮下面的代碼定時器在Delphi
Timer1 .Enabled := False;
Timer1.Interval : = 300;
For I := 1 to NumberOfTimesNeed do
Begin
Timer1 .Enabled := False; //
Timer1 .Enabled := True; // reset the timer to 0.30 seconds
TakesToLong := False;
DoSomethingThatTakesTime; // Application.ProcessMessages is called in the procedure
If TakesToLong = True then
TakeAction;
End;
procedure Timer1Timer(Sender: TObject);
begin
TakesToLong:= True;
end;
問:
當我禁用,然後啓用定時器1與
Timer1.Enabled := False;
Timer1.Enabled := True;
這是否復位定時器?
即它會在超時之前總是等待0.30秒。
呃,你爲什麼不試試?沒有0.3秒的空閒時間? ;) – 2009-02-08 14:27:37