Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2007 Oct : Threads
| Subject: | Threads |
| Posted by: | "Marco Cotroneo" (m.c..@ritoll.it) |
| Date: | Wed, 24 Oct 2007 10:12:25 |
Hello!
I have create this simple thread class, I am posting down below, but
I can't understand why it does not work right. It simply shows a form
and update its caption with the current time.
If I fire two istances of the same thread and two istances of the
same form, one of those forms is not updated (I don't see seconds running).
If I change the left property of to one of the forms, before showing
it, everything seems to work fine. But if I move one form with the
mouse one form (not always the same) stop updating. Where am I wronging?
thanks
Marco
procedure TForm1.Button2Click(Sender: TObject);
begin
with TThrd.Create(true) do
begin
aForm := TForm2.create(self);
FreeOnTerminate:= true;
Resume;
end;
with TThrd.Create(true) do
begin
aForm := TForm2.create(self);
FreeOnTerminate:= true;
Resume;
end;
end;
TThrd = class(TThread)
private
Flbl: TLabel;
FForm: TForm;
protected
procedure Execute; override;
procedure VisualUpdate;
public
property aLbl: Tlabel read Flbl write Flbl;
property aForm: TForm read FForm write FForm;
end;
...
procedure TThrd.Execute;
begin
Synchronize(aForm.Show);
repeat
Synchronize(VisualUpdate);
until Application.Terminated;
end;
procedure TThrd.VisualUpdate;
begin
aForm.Caption := FormatDateTime('hh:nn:ss', now);
aForm.Update;
application.processMessages;
end;