uRe: Why doesn't my thread terminate?
- From: "Skybuck Flying" <BloodyShame@xxxxxxxxxxx>
- Date: Fri, 2 May 2008 20:52:26 +0200
Ok,
You probably doing many things wrong, here is a example/snippet how it
could/should look like:
type
TMyThread = ...
mStart : TnotifyEvent;
mStop : TnotifyEvent;
mUpdateEditBox : TnotifyEvent;
etc;
end;
procedure TMyThread.DoStart;
begin
if Assigned(mStart) then mStart(Self);
end;
procedure TMyThread.DoStop;
begin
if Assigned(mStop) then mStop(Self);
end;
procedure TMyThread.DoUpdateEditBox;
begin
if Assigned(mUpdateEditBox) then mUpdateExitBox(Self);
end;
procedure TMyThread.Execute;
begin
// fire start event
Synchronize(DoStart);
while not Terminated do
begin
// timing code goes here, for example:
sleep( 1000 );
// or for more precision see query performance counter api.
// fire update event
Synchronize(DoUpdateEditBox);
end;
// fire stop event
Synchronize(DoStop);
end;
Then in the button event handlers when you wanna stop the thread write
something like:
MyThread.Terminate;
Bye,
Skybuck.
.
- Follow-Ups:
- Re: uRe: Why doesn't my thread terminate?
- From: Prodigal Son
- Re: uRe: Why doesn't my thread terminate?
- References:
- Why doesn't my thread terminate?
- From: Prodigal Son
- Why doesn't my thread terminate?
- Prev by Date: Why doesn't my thread terminate?
- Next by Date: Re: Why doesn't my thread terminate?
- Previous by thread: Why doesn't my thread terminate?
- Next by thread: Re: uRe: Why doesn't my thread terminate?
- Index(es):