Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-02

Context of TThread.OnTerminate

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Wimpie Nortje

Hi everybody,

The manual (possibly Delphi one) says that TThread.OnTerminate executes in the GUI thread. This is easy if the GUI thread owns the TThread.

Suppose the GUI owns a TTHread which owns a subthread. In which context does the subthread's OnTerminate execute?

Thanks

Reply by email

Mattias Gaertner
to Wimpie Nortje
Show quoted text 7 lines
Hi everybody, The manual (possibly Delphi one) says that TThread.OnTerminate executes in the GUI thread. This is easy if the GUI thread owns the TThread. Suppose the GUI owns a TTHread which owns a subthread. In which context does the subthread's OnTerminate execute?

Under unix OnTerminate is always called in the main thread:

procedure TThread.CallOnTerminate;
begin
  // no need to check if FOnTerminate  nil, because
  // thats already done in DoTerminate
  FOnTerminate(self);
end;
procedure TThread.DoTerminate;
begin
  if Assigned(FOnTerminate) then
    Synchronize(@CallOnTerminate);
end;

Mattias

Reply by email

Unknown author
to Wimpie Nortje: The manual (possibly Delphi one) says that TThread.OnTerminate executes in the GUI…
Wimpie Nortje wrote 7 lines
Hi everybody, The manual (possibly Delphi one) says that TThread.OnTerminate executes in the GUI thread. This is easy if the GUI thread owns the TThread. Suppose the GUI owns a TTHread which owns a subthread. In which context does the subthread's OnTerminate execute?

Always the main thread; no matter in which thread a thread was started.

There simply is no information about which thread has started another particular thread.

Michael.

Reply by email

Wimpie Nortje
to Unknown author

Thanks Mattias and Michael

Show quoted text 22 lines
On Thu, 24 Feb 2011, Wimpie Nortje wrote: > Hi everybody, > > The manual (possibly Delphi one) says that TThread.OnTerminate executes > in the GUI thread. This is easy if the GUI thread owns the TThread. > > Suppose the GUI owns a TTHread which owns a subthread. In which context > does the subthread's OnTerminate execute? Always the main thread; no matter in which thread a thread was started. There simply is no information about which thread has started another particular thread. Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email