Synchronize configuration between master and slaves NET Worker Service app as a Windows Service, it's recommended that you publish the app as a single file executable. The hosted service is registered for dependency injection.įor more information on registering services, see Dependency injection in. The service name is set to ".NET Joke Service". The UseWindowsService extension method configures the app to work as a Windows Service. LoggerProviderOptions.RegisterProviderOptions(services) ConfigureServices((context, services) => Options.ServiceName = ".NET Joke Service" IHostBuilder builder = Host.CreateDefaultBuilder(args) Logs are written to, and available for viewing in the Event Viewer. In this case, the logger is implemented by the Windows Event Log - .EventLogLogger. In the ExecuteAsync method, the joke service requests a joke and writes it to the logger. Both are made available to the class as private readonly fields. In the preceding code, the JokeService is injected along with an ILogger. recovery options, we need to terminate the process with a non-zero exit code. In order for the Windows Service Management system to leverage configured When set to "StopHost": will cleanly stop the host, and log errors. When set to "Ignore": will do nothing at all, errors cause zombie services. This is required to avoid the 'BackgroundServiceExceptionBehavior', which Terminates this process and returns an exit code to the operating system.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |