<p>Am 06.05.2016 11:34 schrieb "LacaK" <<a href="mailto:lacak@zoznam.sk">lacak@zoznam.sk</a>>:<br>
><br>
> Hi *,<br>
> is this safe:<br>
><br>
> FThread.Terminate; // what if here is switched FThread to execution and will immediately end his Execute procedure<br>
> FThread.WaitFor; // what happens if FThread is freed before WaitFor is executed<br>
><br>
> ?<br>
><br>
> assuming, that FThread has FreeOnTerminate := True;<br>
> (looking into source code it can IMO happen, that ThreadProc is ended and data allocated to FThread instance are freed thanks to FreeOnTerminate)<br>
><br>
> Is there any technique, when I need wait for thread to end execution and still have FreeOnTerminate = True ?</p>
<p>Either don't use FreeOnTerminate in that case or use an event that is owned outside of the thread and that is triggered before exiting the thread's Execute method.</p>
<p>Regards,<br>
Sven</p>