We have a .NET Windows service that shovels a lot of highly critical data from A to B in a transactional manner. We also need to make sure that all external compontents used in the service are unallocated correctly and everything cleaned up before shutting down the service itself. This can take hours! The reason for this is that the service needs to wait on an external component's callback, which arrives 2, 3, or 4 hours later.
- is it possible for Windows to wait so long for a service to shutdown gracefully?
- are there options in a service where I can dictate what happens when the service is being shutdown by the operating system, e.g. prevent the shutdown altogether?
- also, as another scenario, what happens if the server needs to reboot? Can it wait hours for the service?
- Is there a limit on how long the OS will wait on the service before killing it?