Windows Service and Recovery

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a service which I create in vb.net. I'm trying to use the Recovery
feature of Windows 2000/XP to restart the service if it fails to start. Looks
like there are some steps that a service must perform for this feature to
work, like settings the value of WIN32_EXIT_CODE. Does anyone know how to
write a service using .net so it can use Recovery feature of Windows?

Thanks
Mike
 
Ok, I answer my question:

I talked to Microsoft technical support and apparently, it's not a good idea
to use "Service Recovery" feature of Windows 2000/XP. Here is what I did
after getting ideas from them:
- In OnStart event, create a new thread to initialize the service. This way
the "Service Start" will be successful.
- If it fails (for example, because SQL server is not ready yet), use
Thread.Sleep to wait for some time and then try to initialize the service
again.
- You can choose the number of retries and delay between each.
- You have the option to stop your service after certain number of retries.
- You may want to log each retry in the event log, along with how many times
you will retry, and delay between each retry.
 
Back
Top