[DUG] Terminating a thread

Conor Boyd Conor.Boyd at trimble.co.nz
Fri Sep 22 10:23:24 NZST 2006


No worries.

YMMV.

Sounds like you've got something that does what you want now anyways.

C. 

-----Original Message-----
From: delphi-bounces at ns3.123.co.nz [mailto:delphi-bounces at ns3.123.co.nz]
On Behalf Of Nick Fauchelle

Indeed, I am wanting to keep the label updated.
And with the TTimer I could keep the label updated every second, but if
I just put

Synchronize(UpdateLabel)
in various places in the Thread then it could go for a few seconds
without being updated... which again is why I used a TTimer.

So really, I should move the TTimer out of the thread.
And start it when I call
MyThread := TMyThread.create...
ProgTimer.enabled := false;


and then
MyThread.Terminate;
ProgTimer.enabled := false;

and 

procedure TForm1.ProgTimerOnTimer...
begin
//update label
end

Thanks :-)
Nick



Conor Boyd wrote:
> If you're wanting to see how long the thread takes, you'd be better to

> just save the value of Now to a temporary StartTime variable or 
> similar before you start your thread, and then in your OnTerminate 
> method you can subtract that value from the current value of Now() to 
> get the elapsed time.
>
> I don't see why you'd use a TTimer to find out how long something is 
> taking.  TTimer is for causing an event to fire at particular
intervals.
>
> If you want to keep the label updated as your thread executes you 
> could have an UpdateLabel method on your form which calculates the 
> elapsed time since StartTime, and then from within the loop in your 
> thread's Execute method, use Synchronize(UpdateLabel) to actually tell

> the form to update the label.

[snip]



More information about the Delphi mailing list