开发者

c#: How do I run multiple windows services as one service?

I have three windows services in one C# project. Using the installer class (it contains three service installers and one process installer) I was able to install 开发者_如何学Pythonall of my services and start them as three different windows services.

Now I'm trying to run those services under one service name (I would like to see one service name in service control manager, not three). What would be the best approach to do this?

Thanks in advance!


You could just have one main service that spawns off the other executables as regular processes (see Process.Start(..)) which would not show up as windows services. That service would have to control the life time of the dependent processes (start them after the service was started /stop them before shutdown).


Create a new windows service and start 3 thread.


All you have to do is implement some principles of code reuse.

Move each of the respective work units into classes/libraries rather than services. Create a single service referencing the end result libraries. Your service intention is likely a timer of some sort, and possibly exposing API endpoints. Create the single service and activate the necessary classes from 3 unique timers (if needed - you might get away with a single timer activating 3 different class methods). Wrap events or API endpoints in a similar fashion. A services should contain little or no "business" logic, it should derive that work from referenced business libraries. Follow that practice and your question will mostly answer it's self.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜