Fórum A thread nao era pra rodar independente do sistema? #309743
18/01/2006
0
Obrigado!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TXThread = class( TThread )
protected
procedure Execute; override;
end;
var
Form1: TForm1;
T1 : TXThread;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
T1 := TXThread.Create(True);
T1.Execute;
Timer1.Enabled := True;
end;
procedure TXThread.Execute;
begin
sleep(6000);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Label1.caption := TimeToStr(Time);
end;
end.
Tiagops
Curtir tópico
+ 0Posts
18/01/2006
Massuda
procedure TForm1.Button1Click(Sender: TObject); begin T1 := TXThread.Create(True); T1.Resume; Timer1.Enabled := True; end;
Como você está chamando diretamente TThread.Execute, esse método é executado dentro da thread principal do programa, não dentro da thread que você criou.
Gostei + 0
18/01/2006
Tiagops
Valeu
Gostei + 0
18/01/2006
Martins
procedure TForm1.Button1Click(Sender: TObject); begin T1 := TXThread.Create(True); T1.Resume; Timer1.Enabled := True; end;
Boa [b:5532b6a6ab]Massuda[/b:5532b6a6ab], cara sou teu fã, :D
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)