Reputation: 1335
OK, I have never made a windows service before so sorry if this question seems a bit dumb. I currently have a windows form application with a few buttons that perform certain operations. When the buttons have been clicked these operations currently would run infinitely using a timer that i set up.
I want to set this up as a windows service, but do not really know how to. There are a lot of examples of creating a service as another project, but is this what I want or can i include it within my existing project? How would i take the process of actually having to click on these buttons once and placing that within the service?
Upvotes: 2
Views: 1564
Reputation: 2018
Steps:
Code: http://pastebin.com/BAFH27wB
Upvotes: 0
Reputation: 1309
I would highly recommend creating a Console Application to run your service, and then use TopShelf.
This will enable you to run your application easily for debugging by just launching your Exe and you can write all your debug messages to the Console window, but it has built in code to allow you to install your Exe as a windows service and will use the same code.
You can read more about Topshelf at http://docs.topshelf-project.com/en/latest/overview/index.html.
When you are happy that your program is working as expected, you can then install your executable as a windows service
There are several options you can pass for installing your service, which you can find here. http://docs.topshelf-project.com/en/latest/overview/commandline.html
Upvotes: 2
Reputation: 94
You should try to use Topshelf in your C# application. It is really easy to use and well documented. When you add this nuget package into you project and configure it in C# code, then simple command
you_app.exe -install
is everything you need. For more details please have a look here:
http://topshelf.readthedocs.org/en/latest/index.html http://topshelf.readthedocs.org/en/latest/configuration/quickstart.html
Upvotes: 0