. , , , .
Suspend - . co. Suspend. Resume.
Priority - . Priority:=tpIdle;
tpIdle - , .
tpLowest -
tpLower -
tpNormal -
tpHigher -
tpHighest -
tpTimeCritical - ( , ).
Suspended - true, .
Terminated - true, , .
Terminate .
FreeOnTerminate true, Execute . , , .
, Execute FreeOnTerminate:
procedure TCountObj.Execute;
begin
FreeOnTerminate:=true;
index:=1;
//
while index>0 do
begin
Synchronize(UpdateLabel);
Inc(index);
if index>100000 then
index:=0;
// , .
if terminated then exit;
end;
end;
, . TThread , .
. . , . , . , . . , .
UpdateLabel, index. , index Execute, UpdateLabel . . - , Synchronize, . , Synchronize.
|
|
. Windows. , , SendMessage , . . , , .
, SendMessage :
1. (), .
2. .
3. .
4. .
, , Handle. TLabel, , , . TEdit. . uses : windows ( ) messages ( Windows).
UpdateLabel, , Synchronize. , Execute:
procedure TCountObj.Execute;
begin
index:=1;
while index>0 do
begin
SendMessage(Form1.Edit1.Handle, WM_SETTEXT, 0,
Integer(PChar(IntToStr(index))));
Inc(index);
if index>100000 then
index:=0;
if terminated then exit;
end;
end;
, Synchronize TEdit. WM_SETTEXT . . , . . , PChar. index (IntToStr), PChar Integer.
, 1, , Word, Word.