Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Running Service Continuously – Delphi

My service does not seem to continuously run.

procedure TService1.ServiceExecute(Sender: TService);
begin
While not Terminated do
  ServiceThread.ProcessRequests(True);
end;

This is what I currently have that is suppose to be keeping the service running, but it does not do so.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

This bit of code only runs when the service is started from the Windows Service Manager. Once you have your service .exe file, use a command prompt to start it with the /install command line argument, and use net start <your-service-name> or the Service Management dailog from the Administrative Tools from the Start Menu or Control Panel to start the service.

If you want to run the service in the Delphi debugger, start Delphi with administrative privileges and attach to the running process. But it’s more advisable to have all logic in separate units, and have a separate version of the project as a ‘plain exe’ the run the project’s procedures that you can run in the debugger.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading