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/MicroserviceDemo/applications/ConsoleClientDemo/ConsoleClientDemoHostedServ...

34 lines
1005 B

using Microsoft.Extensions.Hosting;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
using Serilog;
namespace ConsoleClientDemo
{
public class ConsoleClientDemoHostedService : IHostedService
{
public async Task StartAsync(CancellationToken cancellationToken)
{
using (var application = AbpApplicationFactory.Create<ConsoleClientDemoModule>(options =>
{
options.Services.AddLogging(loggingBuilder =>
{
loggingBuilder.AddSerilog(dispose: true);
});
}))
{
application.Initialize();
var demo = application.ServiceProvider.GetRequiredService<ClientDemoService>();
await demo.RunAsync();
application.Shutdown();
}
}
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
}
}