You are a very good developer and have created a great windows service that works like a charm and your CEO likes the functionality and would love to have your SharePoint Administrator control it from the SharePoint Central Administration Site !!!!
What a lovely scenario 🙂
But what also is interesting in this is, that the usual way to control windows services will not work properly when used from within the SharePoint. So then how do you do it? Well, SharePoint itself comes to our rescue and provides us a couple of classes knows as SPWindowsService and SPServiceInstance which will allow you to control your windows service from SharePoint.
Well, there are a few steps that you need to follow to make sure you are able to control and use the windows service from within the SharePoint’s context.
- Use the classes SPWindowsService and SPServiceInstance classes to wrap the Windows Service.
- Add these services to the Services to the servers of the farm.
- Register the service to the desired servers in the farm.
- Provide custom aspx pages (as Application Pages) that can be used to start/stop the service.
- Use SPJobDefinition to start the service. This way, the service can also be started on a remote server.
For further reading, I would suggest that you go through this article in April 2009 edition of MSDN magazine.