J
jensia
Unregistered / Unconfirmed
GUEST, unregistred user!
type
TPRThread = class(TThread)
private
lGuage:TGauge;
{ Private declarations }
proceduredo
Something;
protected
procedure Execute;
override;
public
constructor Create(AGuage:TGauge);
end;
implementation
{ TPRThread }
constructor TPRThread.Create(AGuage:TGauge);
begin
Inherited Create(false);
lGuage:=AGuage;
FreeOnTerminate:=true;
end;
procedure TPRThread.Execute;
begin
Synchronize(doSomething);
if Terminated then
exit;
{ Place thread code here }
end;
procedure TPRThread.doSomething;
var
i:integer;
begin
for i:=0 to 1000do
begin
lGuage.Progress:=i;
sleep(100);
end;
end;
end.
然后在Form里創建線程:
lPRThread:=TPRThread.Create(Gauge1);
//Create Tmp Table
問題是:
會陷入死循環.為何???請問哪位高手可以給出相同的原碼?還是哪里有比較好的例子可以下載.
TPRThread = class(TThread)
private
lGuage:TGauge;
{ Private declarations }
proceduredo
Something;
protected
procedure Execute;
override;
public
constructor Create(AGuage:TGauge);
end;
implementation
{ TPRThread }
constructor TPRThread.Create(AGuage:TGauge);
begin
Inherited Create(false);
lGuage:=AGuage;
FreeOnTerminate:=true;
end;
procedure TPRThread.Execute;
begin
Synchronize(doSomething);
if Terminated then
exit;
{ Place thread code here }
end;
procedure TPRThread.doSomething;
var
i:integer;
begin
for i:=0 to 1000do
begin
lGuage.Progress:=i;
sleep(100);
end;
end;
end.
然后在Form里創建線程:
lPRThread:=TPRThread.Create(Gauge1);
//Create Tmp Table
問題是:
會陷入死循環.為何???請問哪位高手可以給出相同的原碼?還是哪里有比較好的例子可以下載.