❔ Windows BackgroundService
Hello. So I'm a beginner at C# and a beginner and making services, so I'm not sure how stupid some one the questions I'm about to ask might sound. Regardless I would really appreciate if someone could either explain me things or link to useful documentation.
I have the following questions regarding Windows Services in C#:
1- From my understanding, the flow of the Service goes as follows (I'll be referring to
In the
2- Still regarding
I have the following questions regarding Windows Services in C#:
1- From my understanding, the flow of the Service goes as follows (I'll be referring to
BackgroundServices, since that is what the documentation advice me to use, apparently it's the modern approach to making a Service in Windows):In the
Program.cs file, we have a builder, we give the builder information about the classes that are going to do tasks (?) and then we tell it to .Run(). So I assume this is the code that will run when in the shell I do sc.exe create <service_name.exe>. Please correct me If I'm wrong. Then I need to start the service so that it starts doing the thing I tell it to do, and I would stop it if I wanted to stop the service. To kill the service I would need to delete it. This would all be done using the sc.exe.2- Still regarding
Program.cs, what is a HostApplicationBuilder, and why do I need one? The documentation that I followed (https://learn.microsoft.com/en-us/dotnet/core/extensions/windows-service) used a bunch of Host stuff in the Program.cs file but didn't really explained what was going on, so this is my biggest question mark so far, is what is going on with the Program.cs file.