I would like to terminate a Delphi application without executing any other code line and I'm wondering about which is the proper way to do this. Furthermore, I would like to know if there's something wrong in what I'm actually doing at the moment. Basically, my code looks like this:
//Freeing all objects (Obj1.Free, etc..)
Application.Terminate;
Halt;
Is this the right way to stop a Delphi application or should it be done in another way?
Application.Terminate()
breaks the message loops inTApplication.Run()
andTForm.ShowModal()
, allowing the main thread to exit normally, perform necessary cleanups, etc.Vcl.Forms.TApplication.Terminate
Halt()
, on the other hand, is an immediate abnormal termination. Basically, ripping the process out of memory. Use it only in extreme situations where no other option is available.System.Halt