Fixed Warnings
This commit is contained in:
@@ -37,7 +37,7 @@ public partial class App : Application
|
||||
// catch all unhandled errors
|
||||
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
|
||||
|
||||
HostApplicationBuilder builder = Host.CreateApplicationBuilder();
|
||||
HostApplicationBuilder builder = Microsoft.Extensions.Hosting.Host.CreateApplicationBuilder();
|
||||
|
||||
builder
|
||||
/*
|
||||
@@ -87,24 +87,24 @@ public partial class App : Application
|
||||
|
||||
services
|
||||
.AddSingleton<MainViewModel>()
|
||||
.AddSingleton<MainWindow>(service => new MainWindow
|
||||
.AddSingleton(service => new MainWindow
|
||||
{
|
||||
DataContext = service.GetRequiredService<MainViewModel>()
|
||||
});
|
||||
|
||||
_host = builder.Build();
|
||||
_cancellationTokenSource = new();
|
||||
Host = builder.Build();
|
||||
CancellationTokenSource = new();
|
||||
|
||||
try
|
||||
{
|
||||
LogStartingMode();
|
||||
|
||||
// set and show
|
||||
desktop.MainWindow = _host.Services.GetRequiredService<MainWindow>();
|
||||
desktop.MainWindow = Host.Services.GetRequiredService<MainWindow>();
|
||||
desktop.ShutdownRequested += OnShutdownRequested;
|
||||
|
||||
// startup background services
|
||||
_ = _host.StartAsync(_cancellationTokenSource.Token);
|
||||
_ = Host.StartAsync(CancellationTokenSource.Token);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
@@ -131,15 +131,13 @@ public partial class App : Application
|
||||
}
|
||||
}
|
||||
private void OnShutdownRequested(object? sender, ShutdownRequestedEventArgs e)
|
||||
=> _ = _host!.StopAsync(_cancellationTokenSource!.Token);
|
||||
=> _ = Host?.StopAsync(CancellationTokenSource!.Token);
|
||||
|
||||
#region Fields
|
||||
|
||||
private IHost? _host;
|
||||
private CancellationTokenSource? _cancellationTokenSource;
|
||||
|
||||
#endregion
|
||||
|
||||
private IHost? Host { get; set; }
|
||||
private CancellationTokenSource? CancellationTokenSource { get; set; }
|
||||
|
||||
|
||||
private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||
=> ShowMessageBox("Unhandled Error", ((Exception)e.ExceptionObject).Message);
|
||||
|
||||
@@ -161,7 +159,7 @@ public partial class App : Application
|
||||
StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
// initialize a logger & EventId
|
||||
ILogger<App> logger = _host!.Services.GetRequiredService<ILogger<App>>();
|
||||
ILogger<App> logger = Host!.Services.GetRequiredService<ILogger<App>>();
|
||||
EventId eventId = new EventId(id: 0, name: Assembly.GetEntryAssembly()!.GetName().Name);
|
||||
|
||||
// log a test pattern for each log level
|
||||
|
||||
Reference in New Issue
Block a user