look into services. there is good support for service control in the .Net framework.