You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
abp/samples/BasicConsoleApplication/AbpConsoleDemo/AppHostedService.cs

33 lines
953 B

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<AppModule>(options =>
{
options.UseAutofac(); //Autofac integration
}))
{
application.Initialize();
//Resolve a service and use it
var helloWorldService = application.ServiceProvider.GetService<HelloWorldService>();
helloWorldService.SayHello();
application.Shutdown();
}
return Task.CompletedTask;
}
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
}
}