开发者

C#, Windows Services: ServiceBase.Run with several services of the same type

开发者 https://www.devze.com 2022-12-25 17:52 出处:网络
I\'m trying to run several similar services via ServiceBase.Run(ServiceBase[] ) but it\'s only running the first one.MSDN doesn\'t explicitly deny this; does this excerpt mean that they all must be di

I'm trying to run several similar services via ServiceBase.Run(ServiceBase[] ) but it's only running the first one. MSDN doesn't explicitly deny this; does this excerpt mean that they all must be different types? (the bold is by me, not MSDN)

Call this overload in the main() function of the service executa开发者_开发技巧ble to load an array of associated services.


That is the intent. The idea here is that you can have a single executable create "multiple services" instead of just a single type of service.

When a service is registered with the SCM, it's expected that each service is unique. This would suggest (and I believe it's the case) that each element in your array must be a unique implementation of ServiceBase.

If you really are just trying to have multiple copies of the same service, I would rethink your design. Just have the service fire off multiple threads using the same method, and it will provide that same effect with a single service instance.

0

精彩评论

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