CloseAntiFreeze required before thread destruction?

delphi package - automated exception handling

CloseAntiFreeze required before thread destruction?

Postby wprins » Mon Feb 05, 2018 11:16 am


Is it mandatory to call CloseAntiFreeze before or on thread destruction (from the same thread that the InitAntiFreeze was called from), or is it OK to omit doing this and leave it up to the thread destruction? (That is, will thread destruction eventually also cause CloseAntiFreeze to be called automatically for a thread if required, or alternatively does it not matter if it's not called?)

(Background: I'm trying to plumb in some anti-freeze checking into a datasnap server but it's not exactly straightforward to ensure this gets called from the right thread as some cleanup/destruction calls of datasnap service objects seem to be handled not in the same thread they were created in for whatever reason.)


Posts: 7
Joined: Mon Mar 21, 2011 9:51 am

Re: CloseAntiFreeze required before thread destruction?

Postby madshi » Mon Feb 05, 2018 11:33 am

That's a difficult question. AntiFreeze checking involves a window and an additional thread. The thread can be closed fine from the context of another thread. However, I'm not sure what happens to the window if the thread which called InitAntiFreeze closes down. I suppose the window probably dies. At that point probably also the whole freeze checking will die.

I suppose the best option would be to call InitAntiFreeze either from within the main thread. Or to create a dedicated thread for just freeze checking, to make sure the window survives as long as you want freeze checking to stay active. The anti freeze window is created in the context of the thread which calls InitAntiFreeze.
Site Admin
Posts: 9618
Joined: Sun Mar 21, 2004 5:25 pm

Return to madExcept

Who is online

Users browsing this forum: No registered users and 4 guests