Stop flow in delphi

How can I finish the thread correctly? When the thread ends, it is still in memory. I am using Delphi 2010 (update 5).

+5
source share
3 answers

As I usually describe the problems of stopping the flow, cooperation must be emphasized. You must not interrupt the flow. Instead, you should notify the thread that you want it to terminate. Then you politely wait until it ends.

The reasons for this are obvious. Only the stream knows how to finish itself. Only the thread knows what locks it holds, what resources it needs to release, etc.

, . , , .

Delphi TThread Thread.Terminate. , . . TThread.Execute. Terminated. , . , exit (, ..).

+12

? Terminate, , . ( TThread, ), TerminateThread WinAPI. , ( TerminateThread).

+3

All Articles