Skip to content

Commit

Permalink
Testing new changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Simnico99 committed Jan 11, 2023
1 parent 16ba97b commit f105c0d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/ZirconNet.WPF/Hosting/Lifetime/UseWpfApplicationLifetime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public static IHostBuilder UseWpfApplicationLifetime(this IHostBuilder builder,
public static Task RunWpfApplicationAsync<T>(this IHostBuilder builder, CancellationToken cancellationToken = default) where T : Window
{
builder.ConfigureServices(services => services.AddSingleton<T>());
using var host = builder.UseWpfApplicationLifetime().Build();

var window = host.Services.GetRequiredService<T>();

return Task.Run(async () =>
{
using var host = builder.UseWpfApplicationLifetime().Build();
var window = host.Services.GetRequiredService<T>();

await host.StartAsync(cancellationToken);
await window.ShowDialogAsync();
await host.StopAsync();
Expand All @@ -73,11 +73,12 @@ public static Task RunWpfApplicationAsync<T>(this IHostBuilder builder, Cancella
public static Task RunWpfApplicationAsync<T>(this IHostBuilder builder, Action<WpfApplicationLifetimeOptions> configureOptions, CancellationToken cancellationToken = default) where T : Window
{
builder.ConfigureServices(services => services.AddSingleton<T>());
using var host = builder.UseWpfApplicationLifetime(configureOptions).Build();
var window = host.Services.GetRequiredService<T>();

return Task.Run(async () =>
{
using var host = builder.UseWpfApplicationLifetime(configureOptions).Build();
var window = host.Services.GetRequiredService<T>();

await host.StartAsync(cancellationToken);
await window.ShowDialogAsync();
await host.StopAsync();
Expand Down

0 comments on commit f105c0d

Please sign in to comment.