C#, Windows Services: ServiceBase.Run with several services of the same type
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.
精彩评论