Should I use only one new service () or more?

I created a windows service project. And if you create a new project, you will get something like this:

ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[] 
{ 
  new Service1() 
};
ServiceBase.Run(ServicesToRun);

And now I need to add some functions and a timer to my class Service1(), and then everything will be fine.

Now let me say that my service has to do some things, such as: reading some files, deleting some folders, checking connections ...

And they should all be running async. Which is better now? Copy all the functions in Service1 () and do not change anything else or create a new class for each “material” (Service1 (), Service2 (), ...) and add them as

ServicesToRun = new ServiceBase[] 
{ 
  new Service1(),
  new Service2() //not sure this will compile
};

Just asking. Maybe I didn’t understand 100% how the services work ...

+5
source share
1 answer

, Windows . , , , , , , :

  • . , , , , .
  • (.. ), . , , .
0

All Articles