<div dir="auto"><div class="gmail_quote" dir="auto"><div dir="ltr">Am Fr., 14. Dez. 2018, 11:23 hat Michael Van Canneyt <<a href="mailto:michael@freepascal.org">michael@freepascal.org</a>> geschrieben:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
On Fri, 14 Dec 2018, Sven Barth via fpc-pascal wrote:<br>
<br>
> Am Fr., 14. Dez. 2018, 10:31 hat Michael Van Canneyt <<a href="mailto:michael@freepascal.org" target="_blank" rel="noreferrer">michael@freepascal.org</a>><br>
> geschrieben:<br>
><br>
>><br>
>><br>
>> On Fri, 14 Dec 2018, el es wrote:<br>
>><br>
>>> On 13/12/2018 22:23, Michael Van Canneyt wrote:<br>
>>>><br>
>>>><br>
>>>> On Thu, 13 Dec 2018, Martin Frb wrote:<br>
>>>><br>
>>>>><br>
>>>>> ---- Besides, the documentation does not say that FreeOnTerminate<br>
>>>>> is limited to be used in the thread construction. Especially since<br>
>>>>> its effect is not due until "terminate"<br>
>>>><br>
>>>> For me this is a given.<br>
>>>><br>
>>>> Almost by definition, changing anything in a thread after the<br>
>>>> constructor has returned, is dangerous. You should set up everything<br>
>>>> in the constructor.<br>
>>><br>
>>><br>
>>> Then this TThread.FreeOnTerminate property should not really be public,<br>
>>> if it's only to be used in 'private' context of the constructor?<br>
>><br>
>> I think FreeOnTerminate should not even exist. IMO it should simply be<br>
>> 'True'.<br>
>><br>
><br>
> I disagree, because then you could never do a WaitFor(). Or provide the<br>
> thread with new data through a method (that fills a queue that the thread<br>
> processes) without risking an access violation.<br>
<br>
This can be solved with the OnTerminate event. As long as you didn't get<br>
that, the thread is still alive.<br></blockquote></div><div dir="auto"><br></div><div dir="auto">That won't help if multiple threads are involved, because OnTerminate will always arrive on the main thread and a thread using the just terminated thread might be in the middle of a method call to that thread. </div><div dir="auto"><br></div><div dir="auto">Also the argument regarding WaitFor still stands. </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div class="gmail_quote" dir="auto"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"></blockquote></div></div>