Martin Schreiber ha scritto:
On Sunday 30 December 2007 07.39:25 Micha Nelissen wrote:
Martin Schreiber wrote:
You are right, there seems to be no race condition if one uses
WakeMainThread correct. There can be a deadlock if the main thread tries
to destroy a thread which is waiting for Synchronize.
Hmm I think this is a very stupid idea to do. The thread will continue
to execute something so I don't think this is supported. Like destroying
a component in an event handler.
TThread.Destroy calls Waitfor.
What is the supported method to terminate an application which has threads
waiting for Synchronize?
I don't know it it's officially supported, but for me it works.
I've added a Running property to my thread, which is set true when the
thread begins execution, and false jut before terminating.
In my main form, the OnClose event includes:
if assigned(Thr1) then begin
if Thr1.Running then begin
Thr1.Terminate;
Thr1.WaitFor;
end;
end;
By setting true FreeOnTerminate, the thread destroys cleanly itself.
Giuliano
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives