Hi i have created windows services in Delphi. I have installed and started the Services. Every thing working fine. Even i can check it in Task Manager.My service is Running.
But the code which i included inside the OnExecute method is not working.
My whole Code:
unit MyService;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.SvcMgr, Vcl.Dialogs,
Vcl.ExtCtrls,Jira;
type
TJiraTestlink = class(TService)
procedure ServiceExecute(Sender: TService);
private
{ Private declarations }
public
function GetServiceController: TServiceController; override;
{ Public declarations }
end;
var
JiraTestlink: TJiraTestlink;
implementation
{$R *.DFM}
procedure ServiceController(CtrlCode: DWord); stdcall;
begin
JiraTestlink.Controller(CtrlCode);
end;
function TJiraTestlink.GetServiceController: TServiceController;
begin
Result := ServiceController;
end;
procedure TJiraTestlink.ServiceExecute(Sender: TService);
const
SecBetweenRuns = 10;
var
Count: Integer;
begin
Count := 0;
while not Terminated do
begin
Inc(Count);
if Count >= SecBetweenRuns then
begin
Count := 0;
{ place your service code here }
{ this is where the action happens }
ShowMessage(DateTimeToStr(Now));
end;
Sleep(1000);
ServiceThread.ProcessRequests(False);
end;
end;
end.
I am not sure where i did mistake. Any help will be appreciated. Thanks.