using System.Windows;
using Microsoft.Extensions.Hosting;
using Seyounth.Hyosung.Views;
namespace Seyounth.Hyosung.Services;
public class ApplicationHostService(IServiceProvider serviceProvider) : IHostedService
{
///
/// Triggered when the application host is ready to start the service.
///
/// Indicates that the start process has been aborted.
public async Task StartAsync(CancellationToken cancellationToken)
{
await HandleActivationAsync();
}
///
/// Triggered when the application host is performing a graceful shutdown.
///
/// Indicates that the shutdown process should no longer be graceful.
public async Task StopAsync(CancellationToken cancellationToken)
{
await Task.CompletedTask;
}
///
/// Creates main window during activation.
///
private async Task HandleActivationAsync()
{
if (!Application.Current.Windows.OfType().Any())
{
Application.Current.MainWindow = serviceProvider.GetService(typeof(MainWindow)) as MainWindow;
Application.Current.MainWindow.Show();
}
await Task.CompletedTask;
}
}