Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 executable to load an array of associated services.

like image 716
Austin Salonen Avatar asked Apr 02 '10 16:04

Austin Salonen


1 Answers

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.

like image 101
Reed Copsey Avatar answered Oct 05 '22 10:10

Reed Copsey