mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-01-05 23:24:27 +01:00
Add missing file
This commit is contained in:
28
BTCPayServer/Extensions/WebHostExtensions.cs
Normal file
28
BTCPayServer/Extensions/WebHostExtensions.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BTCPayServer.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Microsoft.AspNetCore.Hosting
|
||||
{
|
||||
public static class WebHostExtensions
|
||||
{
|
||||
public static async Task StartWithTasksAsync(this IWebHost webHost, CancellationToken cancellationToken = default)
|
||||
{
|
||||
// Load all tasks from DI
|
||||
var startupTasks = webHost.Services.GetServices<IStartupTask>();
|
||||
|
||||
// Execute all the tasks
|
||||
foreach (var startupTask in startupTasks)
|
||||
{
|
||||
await startupTask.ExecuteAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// Start the tasks as normal
|
||||
await webHost.StartAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user