Halt is utterly final, and no cleanup is required. Halting is the same as doing endprocess in task manager. Everything will be wiped clean to the operating system capability. Unsaved stuff is lost etc etc.
Halt is generally not an ideal way to kill off an application.
The help is from Delphi 7 hlp. After Delphi 7 IMHO the help is pathetic and useless. Even d7 is missing help from older versions that was more relevant and useful. God knows who wrote their help system, but he/she should be hit on the head.
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Paul A Norman
Sent: Saturday, 20 May 2006 11:06 a.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Usage - initialization and finalization
Dear Kyley,
" 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"
Thats the sort of stuff I was looking for in the help systrem. Which version of Delphi (help) was that in?So far I have not found it in D2005.
"As per the help file, which it seems many have not read.. "
You say that Finalization does not happen on halt.
Is there anything that can be caused to do cleanup if halt is executed? Or is it utterly final?
Paul
On 20/05/06, Todd Martin < [EMAIL PROTECTED]> wrote:
Hi Kyley
There is another option. The double check locking pattern. Once instantiated
the critical section is no longer used.
var
SingletonInstance : TSingletonObject;
function GetSingletonInstance : TSingletonObject;
begin
if (SingletonInstance= nil) then
begin
CriticalSection.Enter;
try
if (SingletonInstance= nil) then
begin
SingletonInstance:= TSingletonObject.Create;
end;
finally
CriticalSection.Leave;
end;
end;
Result := SingletonInstance;
end;
----- Original Message -----
From: "Kyley Harris" <[EMAIL PROTECTED]>
To: "NZ Borland Developers Group - Delphi List" < [email protected] >
Sent: Friday, May 19, 2006 4:52 PM
Subject: RE: [DUG] Usage - initialization and finalization
> Thanks. Hadn't thought of that before. It is of course quite possible
> for it to be constructed 2 times. Going back to that code sample I
> posted for observation I use this method for creating a Critical
> Section. This would probably be a good place to use that seeing as I use
> that in a very threaded environment.
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> On Behalf Of Jeremy North
> Sent: Friday, 19 May 2006 2:29 p.m.
> To: NZ Borland Developers Group - Delphi List
> Subject: Re: [DUG] Usage - initialization and finalization
>
> An alternate and thread safe way to perform this operation is to use
> InterlockedCompareExchange.
>
> It is possible (although not very probable) to have FList created
> twice without using InterlockedCompareExchange. Probably not worth the
> extra effort though.
>
> ms-help://borland.bds4/dllproc/base/interlockedcompareexchange.htm
>
> This technique is implemented in the TPrivateHeap class in the
> PrivateHeap unit. It was originally written by Hallvard Vassbotn. If
> you are interested in the inner workings of Delphi and the Compiler,
> you should read his blog ( http://hallvards.blogspot.com/).
>
> For the OP I would minimize the use of the Initialization section to
> cases where you really need it. Otherwise your unit cannot be smart
> linked out.
>
> /// code below
>
> unit Unit4;
>
> interface
>
> uses
> Windows
> , Classes
> , SysUtils
> ;
>
> function GetList: TList;
>
> implementation
>
> var
> FList: TList;
>
> function GetList: TList;
> var
> lList: TList;
> begin
> if FList = nil then
> begin
> lList := TList.Create;
> if InterlockedCompareExchange(Integer(FList), Integer(lList), 0) <>
> 0 then
> lList.Free;
> end;
> result := FList;
> end;
>
> initialization
>
> finalization
> FreeAndNil(FList);
>
> end.
>
> _______________________________________________
> Delphi mailing list
> [email protected]
> http://ns3.123.co.nz/mailman/listinfo/delphi
>
>
>
> _______________________________________________
> Delphi mailing list
> [email protected]
> http://ns3.123.co.nz/mailman/listinfo/delphi
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.392 / Virus Database: 268.5.6/340 - Release Date: 15/05/2006
>
>
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.392 / Virus Database: 268.5.6/340 - Release Date: 15/05/2006
_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi
_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi
_______________________________________________ Delphi mailing list [email protected] http://ns3.123.co.nz/mailman/listinfo/delphi
