C
canna
Unregistered / Unconfirmed
GUEST, unregistred user!
我的需求是:在form上的2个progressbar, 在执行线程语句
progressbar.create(false,ProgressBar1);
progressbar.create(false,ProgressBar2);
时,同时显示进度。而我下面的程序,却是先显示ProgressBar1进度,
再显示ProgressBar2进度。而且在进度变化过程中,不能进行其他操作。
显然,没有实现多线程。
各位,请帮我看看,错在哪里?
unit Unit2;
interface
uses
Classes, Comctrls;
type
progressbar = class(TThread)
private
{ Private declarations }
probar: TProgressBar;
procedure showprogress;
protected
procedure Execute;
override;
public
constructor create(Suspended: Boolean;
ProgressBar: TProgressBar);
end;
implementation
constructor progressbar.create(Suspended: Boolean;
ProgressBar: TProgressBar);
begin
inherited create(Suspended);
probar:=progressBar;
end;
procedure progressbar.showprogress;
var i: integer;
begin
for i:=0 to 1000000do
Probar.position:=round(i/10000);
end;
procedure progressbar.Execute;
begin
Synchronize(showprogress);
end;
end.
progressbar.create(false,ProgressBar1);
progressbar.create(false,ProgressBar2);
时,同时显示进度。而我下面的程序,却是先显示ProgressBar1进度,
再显示ProgressBar2进度。而且在进度变化过程中,不能进行其他操作。
显然,没有实现多线程。
各位,请帮我看看,错在哪里?
unit Unit2;
interface
uses
Classes, Comctrls;
type
progressbar = class(TThread)
private
{ Private declarations }
probar: TProgressBar;
procedure showprogress;
protected
procedure Execute;
override;
public
constructor create(Suspended: Boolean;
ProgressBar: TProgressBar);
end;
implementation
constructor progressbar.create(Suspended: Boolean;
ProgressBar: TProgressBar);
begin
inherited create(Suspended);
probar:=progressBar;
end;
procedure progressbar.showprogress;
var i: integer;
begin
for i:=0 to 1000000do
Probar.position:=round(i/10000);
end;
procedure progressbar.Execute;
begin
Synchronize(showprogress);
end;
end.