Forum > Graphics

How multithreading occurs in TTimer for animation usage?

(1/1)

avv210:
Hey guys. I use the TTimer component in Lazarus for my animation, the method I use is sleep(). How does multithreading occurs in sleep()? Thank you :D

Martin_fr:
1) TTimer does not use threads. TTimer runs in the main thread.

2) Sleep only affects the thread that calls it.
- Other threads are not affected
- The thread that called "sleep" is blocked during the call. If this is the main thread, then timer events will be delayed until after the sleep.

Dzandaa:
Hi,

There is the code I use for non blocking Sleep:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---// ************************************// **** Delay: Non Blocking Sleep *****// ************************************procedure Delay(Milis: qword);var  TimeSpend: qword;begin   TimeSpend := GetTickCount64;  while (GetTickCount64 < TimeSpend + Milis) and (not Application.Terminated) do    Application.ProcessMessages; end;     

Navigation

[0] Message Index

Go to full version