I know how I can create a Wi开发者_开发技巧ndows Service in C# but I have a series of variables that the user currently feeds into a text file and I wanted to control this process. So can I attach a Windows service to a Windows form application to control such things as installing the service, uninstalling the service, start and restart. Or is it better to have them completely separate and just use the form app to run system commands for install/uninstall and use the serviceController to start/restart?
Thanks
I suggest to make it completely separated.
It's probably better to keep them separate: have the form write a config file for the service, then either restart the service or have the service detect the changed file and reconfigure itself.
If the service interacts with the desktop, then you'll have to start worrying about what happens if they're running as different users, or if there isn't a logged-on user at all, or...
You can do it by allowing the service to interact with the desktop. It's an acceptable way of doing it, but saying that, I agree with dario-g!
精彩评论