Re: Delphi threading




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

.



Relevant Pages

  • Re: Solid Thread Code
    ... have a nice set of threaded components which mean you dont have to ... such as the .execute says "runs on the thread" so you know no vcl calls ... the after execute however says it runs on the vcl thread, ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: Solid Thread Code
    ... have a nice set of threaded components which mean you dont have to ... worry too much on what does what as its very clear what you should and ... such as the .execute says "runs on the thread" so you know no vcl calls ... the after execute however says it runs on the vcl thread, ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: PC Word Macro Not Working in Mac Word
    ... The "execute" seems to be ... VBA and AppleScript are both "object-oriented" languages. ... Since, in VBA, we are running within the context of a single application, we ... selection, and that the document that contains it must be the active ...
    (microsoft.public.mac.office.word)
  • Re: Questions regarding Synchronisation in Windows (Spinlocks)
    ... Vista/Longhorn now only ship multiprocessor kernel. ... Interrupts are handled in context of ISR. ... Since Spinlocks execute at DPC/Dispatch level, there is no way for the ... But an interrupt occurs which has an IRQL> DPC Dispatch level OR the ...
    (microsoft.public.win32.programmer.kernel)
  • DMO ImpersonateClient use
    ... the windows account in whose context the SQL Server service is running, ... In order to allow users other than sysadmin, to execute xp_cmdshell, ... It appears that the ImpersonateClient property is never getting used. ...
    (microsoft.public.sqlserver.security)