I have a Windows service written in .NET and I need to be able to self-heal for it.
eg. the service constantly monitors the environment at startup, and as soon as the environment variable reaches threashold, the service must restart itself.
Ask the application to check the environment variable and exit when needed so that the service restarts from the recovery tab for the service. You can do this programmatically if you use code to install the service.