Beispiel #1
0
        public async Task <int> OnExecuteAsync
        (
            CommandLineApplication app,
            CancellationToken cancellationToken = default
        )
        {
            try
            {
                _logger.Info("Starting as windows service...");
                var builder = HostedService.CreateHostBuilder();
                await builder.RunAsWindowsServiceAsync();
            }
            catch (Exception ex)
            {
                _logger.Error(
                    "Could not start as windows service. "
                    + ex.Message);
                app.ShowHelp();
            }

            return(0);
        }