Subject | Re: [IBO] Applicatoin.Terminate |
---|---|
Author | Helen Borrie |
Post date | 2003-04-22T23:59:06Z |
At 10:35 PM 22/04/2003 +1000, you wrote:
question of consistent practice when working with an OO language.
The mainform Close procedure is *designed* to dispatch the
Application.Terminate call to the application object, once it has taken
care of freeing everything it owns and unwound things through its
finalization process. Recommended practice, when using an OO language, is
to let objects do what they were designed to do. It's not different to the
situation where, using IBO, it's a bad idea to write new methods that
attempt to duplicate what the IBO object already "knows" to do
itself. Besides being unnecessary, it may have unforeseen effects on the
object, or on other objects that respond to that object's behaviour.
I always recommend reserving calls to the Application. methods to places
where you're not relying on the OO model, or when it's not available to
you, e.g. in "true" console blocks or applications (where you don't have
access to the events of objects) and for terminating one executable from
another.
cheers,
Helen
> > I just noticed this after I replied. Never callAFAIK, it's not written anywhere in the Delphi help. It's rather a
> > application.terminate from
> > within the application. Call Close on the Main form or datamodule unit.
> >
>
>Helen, this is from Delphi help:
>
>Terminate method (TApplication)
>Ends application execution.
>Delphi syntax:
>procedure Terminate;
>C++ syntax:
>void __fastcall Terminate(void);
>Description
>Call Terminate to end the application programmatically. By calling Terminate
>rather than freeing the application object, you allow the application to
>shut down in an orderly fashion.
>
>Terminate calls the Windows API PostQuitMessage function to perform an
>orderly shutdown of the application. Terminate is not immediate.
>
>Terminate is called automatically on a WM_QUIT message and when the main
>form closes.
>
>.. Sounds like it's an orderly way of forcing your application to shut down.
>Where is it written that this method should not be used?
question of consistent practice when working with an OO language.
The mainform Close procedure is *designed* to dispatch the
Application.Terminate call to the application object, once it has taken
care of freeing everything it owns and unwound things through its
finalization process. Recommended practice, when using an OO language, is
to let objects do what they were designed to do. It's not different to the
situation where, using IBO, it's a bad idea to write new methods that
attempt to duplicate what the IBO object already "knows" to do
itself. Besides being unnecessary, it may have unforeseen effects on the
object, or on other objects that respond to that object's behaviour.
I always recommend reserving calls to the Application. methods to places
where you're not relying on the OO model, or when it's not available to
you, e.g. in "true" console blocks or applications (where you don't have
access to the events of objects) and for terminating one executable from
another.
cheers,
Helen