I'm using a simple windows service app. Some of the code takes around a minute to finish executing. If I want to rollout news changes to production, how do I ensure that even after I stopped the service, the service finished what ever it's executing?
Asked
Active
Viewed 138 times
0
-
Your code to finish up should be in the `OnStop` method in the `ServiceBase` derived class. – Ron Beyer Sep 24 '18 at 13:51
1 Answers
1
Your new service would need to check to make sure the old process isn't running.
How can I verify if a Windows Service is running
A better way would be to fix your service so it can be shutdown in a reasonable length of time. A minute is much too long to stop a service.
Whatever it's doing needs to be able to cleanly stop or roll back on request.

Terry Carmen
- 3,720
- 1
- 16
- 32