Working on BackgroundService
This commit is contained in:
parent
9f4996bc8f
commit
ad4ed12f00
12 changed files with 368 additions and 317 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using Autofac;
|
||||
using Insight.Database;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using PlanTempus.Database.ConfigurationManagementSystem;
|
||||
using PlanTempus.Database.Core.DCL;
|
||||
using PlanTempus.Database.Core.DDL;
|
||||
|
|
@ -189,5 +190,35 @@ namespace PlanTempus.SetupInfrastructure
|
|||
Console.ForegroundColor = ConsoleColor.White;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
async Task Run(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
var host = Host.CreateDefaultBuilder(args)
|
||||
.UseServiceProviderFactory(new Autofac.Extensions.DependencyInjection.AutofacServiceProviderFactory())
|
||||
.ConfigureContainer<ContainerBuilder>((hostContext, builder) =>
|
||||
{
|
||||
var startup = new Startup();
|
||||
var connectionStringParams = new Startup.ConnectionStringTemplateParameters("your_user", "your_password");
|
||||
startup.ConfigureContainer(connectionStringParams);
|
||||
})
|
||||
.ConfigureServices((hostContext, services) =>
|
||||
{
|
||||
// Konfigurer andre services her (hvis nødvendigt)
|
||||
})
|
||||
.Build();
|
||||
|
||||
await host.StartAsync();
|
||||
Console.WriteLine("Host has started.");
|
||||
await host.WaitForShutdownAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Host failed to start: {ex}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue