Hello,
I am using Lazarus (trunk, SVN 56813). When I write a code similar to below I see that Terminated property is True and application instantly free itself and exit.
Definition:
TMyInterfaceServer = class(TCustomApplication)
protected
procedure DoRun; override;
private
LogDir: string;
procedure RunServer();
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
procedure WriteHelp; virtual;
end;
end.
Usage:
var
Application: TMyInterfaceServer;
begin
Application := TMyInterfaceServer.Create(nil);
Application.Run();
Application.RunServer();
while not Application.Terminated do Sleep(1000); // execution instantly exit and do not wait here
Application.Free();
end.
I could not see any FTerminated := False in creation code of TCustomApplication. It seems to be included in Initialize() procedure.
Question is: Is my usage above wrong and I should put it as below?
var
Application: TMyInterfaceServer;
begin
Application := TMyInterfaceServer.Create(nil);
Application.Initialize();
Application.Run();
Application.RunServer();
while not Application.Terminated do Sleep(1000); // execution instantly exit and do not wait here
Application.Free();
end.
Thanks & regards,
Ertan