Hello,
in a couple of programs I'm using this idiom:
FMyThread:=TMyTread.Create;
FMyThread.FreeOnTerminate:=false;
FMyThread.OnTerminate:=@MyThreadTerminate
procedure TMyForm.MyThreadTerminate(Sender:TObject);
begin
//do something with FMyThread then
FreeAndNil(FMyThread);
end;
With fpc
On Thu, Dec 10, 2015 at 10:26:29AM +0100, Luca Olivetti wrote:
> Hello,
>
> in a couple of programs I'm using this idiom:
>
>
> FMyThread:=TMyTread.Create;
> FMyThread.FreeOnTerminate:=false;
> FMyThread.OnTerminate:=@MyThreadTerminate
>
> procedure TMyForm.MyThreadTerminate(Sender:TObject);
>
Am 10.12.2015 11:05 schrieb "Luca Olivetti" :
>
> Hello,
>
> in a couple of programs I'm using this idiom:
>
>
> FMyThread:=TMyTread.Create;
> FMyThread.FreeOnTerminate:=false;
> FMyThread.OnTerminate:=@MyThreadTerminate
>
> procedure TMyForm.MyThreadTerminate(Sender:TObject);
>
El 10/12/15 a les 11:13, Sven Barth ha escrit:
Am 10.12.2015 11:05 schrieb "Luca Olivetti" >:
>
> Hello,
>
> in a couple of programs I'm using this idiom:
>
>
> FMyThread:=TMyTread.Create;
> FMyThread.FreeOnTerminate:=false;
>
On Thu, Dec 10, 2015 at 05:23:41PM +0100, Sven Barth wrote:
> Am 10.12.2015 15:06 schrieb "Henry Vermaak" :
> > Is it worthwhile mentioning that OnTerminate gets called with
> > Synchronize()? I had to dig into the source to verify this.
>
> That would indeed be worth
On Thu, Dec 10, 2015 at 02:49:50PM +0100, Sven Barth wrote:
> Am 10.12.2015 12:15 schrieb "Luca Olivetti" :
> > It's obvious that you cannot free the thread from inside a "normal"
> Synchronize call, it's no so obvious you cannot do it in the
> OnTerminate method, so maybe a note
I use a four method pattern with threads, while reusing the same thread
class everywhere.
1) define a status method to update your user interface based on feedback
from the thread
2) define a terminate method to do clean up when a thread finishes
3) define a work method where the thread does its
Am 10.12.2015 12:15 schrieb "Luca Olivetti" :
> It's obvious that you cannot free the thread from inside a "normal"
Synchronize call, it's no so obvious you cannot do it in the OnTerminate
method, so maybe a note could be added in
>
> http://wiki.freepascal.org/User_Changes_3.0
>
Am 10.12.2015 15:06 schrieb "Henry Vermaak" :
>
> On Thu, Dec 10, 2015 at 02:49:50PM +0100, Sven Barth wrote:
> > Am 10.12.2015 12:15 schrieb "Luca Olivetti" :
> > > It's obvious that you cannot free the thread from inside a "normal"
> > Synchronize call,