Exemplo n.º 1
0
        public async Task StartAsync(
            CancellationToken cancellationToken)
        {
            using var logScope = HostingLogMessages.BeginStartupActionScope(_logger, this);
            HostingLogMessages.StartupActionExecuting(_logger);

            using var serviceScope = _serviceScopeFactory.CreateScope();
            DependencyInjectionLogMessages.ServiceScopeCreated(_logger, serviceScope);

            await OnStartingAsync(
                serviceScope.ServiceProvider,
                cancellationToken);

            HostingLogMessages.StartupActionExecuted(_logger);
            _whenDone.SetResult(null);
        }
Exemplo n.º 2
0
        public async Task StopAsync(
            CancellationToken cancellationToken)
        {
            HostingLogMessages.BehaviorsStopping(_logger);

            await Task.WhenAll(_behaviors
                               .Select(async behavior =>
            {
                using var logScope = HostingLogMessages.BeginBehaviorScope(_logger, behavior);
                HostingLogMessages.BehaviorStopping(_logger);
                await behavior.StopAsync(cancellationToken);
                HostingLogMessages.BehaviorStopped(_logger);
            }));

            HostingLogMessages.BehaviorsStopped(_logger);
        }