Hello
At my form I create TFrame at runtime. At this frame I create background thread with executes commands in endless loop. But when I destroy this frame I should destroy this thread.
I try
thread.Suspend;
thread.Terminate;
FreeAndNil(thread);
but get AV and ThreadError.
How should i destroy thread?
You must make sure that the thread exits its
Executemethod to terminate it properly.Code could be something like this:
Call this when You want to destroy thread: