Step 1 :- Create New Service
Step 2 :- Rename the Service.cs to given name
Step 3 :-
Write the relevant code in separate entities. Always ensure to have single entry and exit of the code. For better handling and thread security, put the code in "Lock" blocks.
Step 4 :-
After developing the entities, call the entry method in Service "OnStart" method.
Step 5 :-
Include System Timer in the service. Make sure to configure the Time Interval settings in Appconfig file. Set the Time interval in "OnStart" Method. Call the appropriate Entry point in the TimeEvent.
Step 6 : - After completing the development, build the application
Step 7 :- Add Installer to the service. After adding the Installer, edit the properties of the ProcessInstaller and Service Installer.
Modify the settings as per needed, so that service runs smoothly.
Step 8 :- Deployment Details
- Create Install.bat and Uninstall .bat files for installing and installing the service
- Include "C:\Windows\Microsoft.NET\Framework\v1.1.4322\InstallUtil.exe /i <Servicename>.exe" in Install.bat file
- Include "C:\Windows\Microsoft.NET\Framework\v1.1.4322\InstallUtil.exe /u <Servicename>.exe" in Uninstall.bat file
- Once the Install.bat file is executed, "InstallUtil.exe.exe" utility will deploy the service into System Services.
Start the service when it is needed. Then onwards the service will get executed for the specified Time Interval.