Delphi timer is faster than timer interrupt routine

Hi, I was asked to support a Delphi 5-based program for someone, and the program uses a timer object to tick every 50 milliseconds, and every time it runs a block of single-threaded code. I'm just wondering what happens if the time taken to execute this block of code is longer than the tick interval, will it be bad? For example, can it cause problems, such as access violation? How does Delphi handle this default situation? Many thanks.

+4
source share
2 answers

Timer keys do not interrupt your code.

- . . , , , , Application.ProcessMessages. ; .

, , .

, , , , . , . , , , , , .

, "", . "", . , . , , wm_Timer. , . , .

:

+6

:

... , , , , ?

, , , , . Delphi TTimer WinAPI SetTimer.

, , , , , . , , . .

WM_TIMER

WM_TIMER . GetMessage PeekMessage , .

Windows "" "" , , , , WM_TIMER - , , GetMessage PeekMessage, SetTimer, , , .

, , , , . , , WM_TIMER.

, , , , . , , , . , . .


, TTimer , 10. :

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  sleep(200);
end;

, . , , 200 ( ).

+6

Source: https://habr.com/ru/post/1684432/


All Articles