delphi multi-threading summary loop


my concentration several threads:
1) sure thread
2) 2 sub-main threads (each summary loop, shown below), used tfqm
3) n workman threads (simple loop, containing sleep())



my problem is, i tie application, workman threads control exit properly, nonetheless 1 2 sub-main threads hangs (never exits) i emanate wm_quit tie them.






procedure threadprocfqm(p: integer); stdcall;
var
msg: tmsg;
_fqm: tfqm;
begin
_fqm := ptr(p);
try
_fqm.fhandle := allocatehwnd(_fqm.wndproc);

while getmessage(msg, 0, 0, 0) do
begin
translatemessage(msg);
dispatchmessage(msg);
end;

finally
deallocatehwnd(_fqm.fhandle);
setevent(_fqm.hterminated);
end;
end;





procedure tfqm.stop;
begin
postmessage(fhandle, wm_quit, 0, 0);

waitforsingleobject(hterminated, infinite);
hthread <> invalid_handle_value then
begin
closehandle(hthread);
hthread := invalid_handle_value;
end;
end;


Comments

Popular posts from this blog

list macos calm editors formula editors

how i practical urls indicate .aspx pages asp.net deployed an iis? (preferably but iis)

jaxb - xjc - reworking generated typesafe enum category members