Thanks for so much Sven. I have another question.<div><br></div><div>Is it okay for a thread to close itself before it's finished? Because I believe that is what happens when FreeOnTerminate is set to True. Here is a brief synopsis of what can execute:</div>
<div><br></div><div>In rtl/objpas/classes/classes.inc</div><div><br></div><div>Line 168: FreeThread := Thread.FFreeOnTerminate; // captures free on termiante</div><div>Line 173: Thread.Free; // invokes the destructor from within the thread</div>
<div>Line 197: CloseThread(FHandle); // thread is closed in destructor TThread.Destroy;</div><div>Line 174: EndThread(Result); // flow returns here, but the thread was already closed</div><div><br></div><div>So what it looks like is that we expect code inside a thread continue running after it has been closed.</div>