Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
procedure tthreadtest.ProcessMessages;
var Msg : Tmsg;
begin
if PeekMessage(Msg, 0, 0, 0, PM_REMOVE) then
begin
if Msg.hwnd = 0 then
begin
case Msg.message of
WM_USER_XXXX : ; handle own thread messages
else
DispatchMessage(Msg); // dispatch message to other handles
end
end
else
DispatchMessage(Msg);
end;
end;
procedure tthreadtest.Execute;
var
mytimer:ttimernew;
begin
//init
try
PeekMessage(msg, 0, WM_USER, WM_USER, PM_NOREMOVE); { Create message queue }
mytimer:=ttimernew.create;
mytimer.Interval:=100;
mytimer.Enabled:=true;
//thread loop
while not terminated do
begin
processmessages;
sleep(20); // avoid 100% cpu time
end;
finally
// cleanup
mytimer.enabled:=false;
if assigned(mytimer) then freeandnil(timer);
end;
end;
procedure tthreadtest.Execute;
begin
//init
try
//thread loop
while not terminated do
begin
// do nothing for x milliseconds
// avoid using large numbers for x since this will
// make your thread unresponsive when Terminate is called (let's say, no longer than 1000 milliseconds)
sleep(x); // avoid 100% cpu time
DoStuff; // this is that would be in the timer event
end;
finally
// cleanup
end;
end;
procedure tthreadtest.Execute;
var Stime : TDateTime;
begin
//init
try
//thread loop
Stime:=Now;
while not terminated do
begin
sleep(20); // avoid 100% cpu time
if SecondsBetween(Now, Stime) > x then
begin
DoStuff;
Stime:=Now;
end;
end;
finally
// cleanup
end;
end;