using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Volo.Abp; namespace AbpConsoleDemo { public class AppHostedService : IHostedService { public Task StartAsync(CancellationToken cancellationToken) { using (var application = AbpApplicationFactory.Create(options => { options.UseAutofac(); //Autofac integration })) { application.Initialize(); //Resolve a service and use it var helloWorldService = application.ServiceProvider.GetService(); helloWorldService.SayHello(); application.Shutdown(); } return Task.CompletedTask; } public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; } }