Finalization is determinate, otherwise your program would blow-up. As I just mentioned in my last email. Initializations and finalizations are dependency based.
As per the help file, which it seems many have not read.. The finalization section is optional and can appear only in units that have an initialization section. The finalization section begins with the reserved word finalization and continues until the end of the unit. It contains statements that are executed when the main program terminates (unless the Halt procedure is used to terminate the program). Use the finalization section to free resources that are allocated in the initialization section. Finalization sections are executed in the opposite order from initializations. For example, if your application initializes units A, B, and C, in that order, it will finalize them in the order C, B, and A. Once a unit's initialization code starts to execute, the corresponding finalization section is guaranteed to execute when the application shuts down. The finalization section must therefore be able to handle incompletely initialized data, since, if a runtime error occurs, the initialization code might not execute completely. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Karl @ Work Sent: Friday, 19 May 2006 5:31 p.m. To: 'NZ Borland Developers Group - Delphi List' Subject: RE: [DUG] Usage - initialization and finalization If you have a "singleton" object that needs to be used, directly or indirectly, in the finalization of other units than the one in which it is declared, what do people do to handle that object's cleanup? Do it using interfaces and reference counting auto-cleanup, or is there a better way? This is assuming that the finalization order of units is not determinate, which it isn't so far as I know... Cheers, Carl _______________________________________________ Delphi mailing list [email protected] http://ns3.123.co.nz/mailman/listinfo/delphi
