Skip to content

Commit

Permalink
Merge pull request #3577 from abpframework/maliming/console-patch
Browse files Browse the repository at this point in the history
Use IHostApplicationLifetime to manually terminate the console application.
  • Loading branch information
hikalkan authored Apr 13, 2020
2 parents b953f16 + 4d347cd commit d10dbfb
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ namespace MyCompanyName.MyProjectName.DbMigrator
{
public class DbMigratorHostedService : IHostedService
{
private readonly IHostApplicationLifetime _hostApplicationLifetime;

public DbMigratorHostedService(IHostApplicationLifetime hostApplicationLifetime)
{
_hostApplicationLifetime = hostApplicationLifetime;
}

public async Task StartAsync(CancellationToken cancellationToken)
{
using (var application = AbpApplicationFactory.Create<MyProjectNameDbMigratorModule>(options =>
Expand All @@ -26,6 +33,8 @@ await application
.MigrateAsync();

application.Shutdown();

_hostApplicationLifetime.StopApplication();
}
}

Expand Down

0 comments on commit d10dbfb

Please sign in to comment.