richard1994x Aprendiz

Registrado: Domingo, 26 de Dezembro de 2010 Mensagens: 162
|
Enviada: Sex Ago 24, 2012 10:54 pm Assunto: [AJUDA] Thread & Loop |
|
|
Como faço os dois loop iniciarem ao mesmo tempo, sem ter que criar duas Threads?
Tentei assim, mas, depois do Until tudo é descartado, também já tentei o for to do.
| Código: | procedure Thread.Execute;
var
i,i2:Integer;
begin
Form1.Gauge1.MinValue:=0;
Form1.Gauge1.MaxValue:=100000000;
Form1.Gauge2.MinValue:=0;
Form1.Gauge2.MaxValue:=100000000;
repeat
Form1.Gauge1.Progress:=i;
inc(i);
until i>1000000000;
repeat
Form1.Gauge2.Progress:=i2;
inc(i2);
until i2>1000000000;
end; |
Código:
| Código: | unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Gauges, StdCtrls;
type
Thread = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
end;
type
TForm1 = class(TForm)
Button1: TButton;
Gauge1: TGauge;
Gauge2: TGauge;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure Thread.Execute;
var
i,i2:Integer;
begin
Form1.Gauge1.MinValue:=0;
Form1.Gauge1.MaxValue:=100000000;
Form1.Gauge2.MinValue:=0;
Form1.Gauge2.MaxValue:=100000000;
repeat
Form1.Gauge1.Progress:=i;
inc(i);
until i>1000000000;
repeat
Form1.Gauge2.Progress:=i2;
inc(i2);
until i2>1000000000;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
varThread:Thread;
begin
varThread:=Thread.Create(True);
varThread.FreeOnTerminate:=True;
varThread.Priority:=tpNormal;
varThread.Resume;
end;
end. |
|
|