Re: Delphi threading
- From: "alanglloyd@xxxxxxx" <alanglloyd@xxxxxxx>
- Date: 20 Aug 2006 22:57:00 -0700
A few comments (although I'm not a thread expert <g>) ...
1 If FreeOnTerminate is true then the thread will free itself when
Execute completes. But note that if Execute is a lengthy procedure then
its code should check Terminated during its execution so that it exits
immediately in a well-behaved manner..
2 Any call to VCL code (such as ShowMessage) must be executed in the
context of the VCL thread because Delphi is not thread-safe. "Executing
in the context of VCL thread" is done by enclosing your call in a
procedure refereced in a call to Synchronize. ie
procedure TMyThread.DisplayMessage;
begin
ShowMessage('SomeThreadValue : ' + IntToStr(SomeThreadValue));
end;
procedure TMyThread.Execute;
begin
// whatever
Synchronize(DisplayMessage);
// whatever
end;
Alan Lloyd
.
- Follow-Ups:
- Re: Delphi threading
- From: DCoder_
- Re: Delphi threading
- References:
- Delphi threading
- From: DCoder_
- Re: Delphi threading
- From: DCoder_
- Re: Delphi threading
- From: DCoder_
- Re: Delphi threading
- From: DCoder_
- Delphi threading
- Prev by Date: Re: Delphi threading
- Next by Date: Need list of running Apps
- Previous by thread: Re: Delphi threading
- Next by thread: Re: Delphi threading
- Index(es):
Relevant Pages
|