Jump to content

If I understand properly, I found critical issue in the TUniGUIService


Tokay

Recommended Posts

Stop event from the system called the OnStart event in the TUniGUIService component.

I look in the IDE and see that call stack:

Vcl.SvcMgr.TService.DoStop

TUniGUIService._StopEvent

TTestService.UniGUIServiceStart

Please look at the issue urgently. Without correct stopping I could not work correctly in the service mode!

I have Delphi XE6, Windows 10, UniGUI 1545 env.

Link to comment
Share on other sites

unit ServiceModule;

interface

uses
 Windows, Messages, SysUtils, Classes, Graphics, Controls, SvcMgr, Dialogs,
 uniGUIService, System.IOUtils;

type
 TUniServiceModule = class(TUniGUIService)
  procedure UniGUIServiceDestroy(Sender: TObject);
  procedure UniGUIServiceCreate(Sender: TObject);
  procedure UniGUIServiceStart(Sender: TService; var Started: boolean);
  procedure UniGUIServiceStop(Sender: TService; var Stopped: boolean);
 private
  { Private declarations }
 protected
  procedure InitService; override;
 public
  { Public declarations }
  function GetServiceController: TServiceController; override;
 end;

var
 UniServiceModule: TUniServiceModule;

implementation

{$R *.dfm}

uses
 UniGUIVars;

procedure ServiceController(CtrlCode: DWord); stdcall;
begin
 UniServiceModule.Controller(CtrlCode);
end;

procedure TUniServiceModule.UniGUIServiceDestroy(Sender: TObject);
begin
 TFile.AppendAllText('D:\Temp\log.txt', 'Destroy' + #13#10);
end;

procedure TUniServiceModule.UniGUIServiceCreate(Sender: TObject);
begin
 TFile.AppendAllText('D:\Temp\log.txt', 'Create' + #13#10);
end;

function TUniServiceModule.GetServiceController: TServiceController;
begin
 Result := ServiceController;
end;

procedure TUniServiceModule.InitService;
begin
 SetServerClass(UniGUIServerModuleClass);
end;

procedure TUniServiceModule.UniGUIServiceStart(Sender: TService; var Started: boolean);
begin
 TFile.AppendAllText('D:\Temp\log.txt', 'Start' + #13#10);
 Started := True;
end;

procedure TUniServiceModule.UniGUIServiceStop(Sender: TService; var Stopped: boolean);
begin
 TFile.AppendAllText('D:\Temp\log.txt', 'Stop' + #13#10);
 Stopped := True;
end;

end.

Create
Start
Start (comment: it's wrong, must be Stop)
Destroy
 

This is code and result of how it works (the service was started after finished).

 

Link to comment
Share on other sites

  • Administrators
procedure TUniGUIService._StopEvent(Sender: TService; var Stopped: Boolean);
begin
  if Assigned(FOnStop) then
    FOnStart(Sender, Stopped);

  if Stopped then
    FreeAndNil(FServerInstance);
end;

Found the problem.

In computer science it is called the Copy/Paste bug and it is root of all errors!

It will be fixed in the next build!

  • Like 1
  • Upvote 1
Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...