Exemple #1
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            await interceptor.OnEngineBeginAsync(scope.ServiceProvider, logger);

            // raise after all event registered
            appLifetime.ApplicationStarted.Register(async state =>
            {
                var self = (ConsoleAppEngineService)state;
                try
                {
                    var engine = new ConsoleAppEngine(self.logger, scope.ServiceProvider, self.interceptor, self.cancellationTokenSource.Token);
                    if (self.methodInfo != null)
                    {
                        self.runningTask = engine.RunAsync(self.type, self.methodInfo, self.args);
                    }
                    else
                    {
                        self.runningTask = engine.RunAsync(self.type, self.args);
                    }

                    await self.runningTask;
                    self.runningTask = null;
                }
                catch { } // don't do anything.
                finally
                {
                    self.appLifetime.StopApplication();
                }
            }, this);
        }
Exemple #2
0
 public ValueTask OnEngineBeginAsync(IServiceProvider serviceProvider, ILogger <ConsoleAppEngine> logger)
 {
     return(innerInterceptor.OnEngineBeginAsync(serviceProvider, logger));
 }