using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
namespace ElectronNET.API
{
///
/// Base class that reports if ASP.NET Core has fully started.
///
internal class LifetimeServiceHost : IHostedService
{
public LifetimeServiceHost(IHostApplicationLifetime lifetime)
{
lifetime.ApplicationStarted.Register(() =>
{
App.Instance.IsReady = true;
Console.WriteLine("ASP.NET Core host has fully started.");
});
}
///
/// Triggered when the application host is ready to start the service.
///
/// Indicates that the start process has been aborted.
public Task StartAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
///
/// Triggered when the application host is performing a graceful shutdown.
///
/// Indicates that the shutdown process should no longer be graceful.
public Task StopAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
}
}