Skip to content

Commit

Permalink
Fixing issue with the host not being stopped. (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
Keboo authored Nov 7, 2023
1 parent 6887e53 commit c51ee7a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Templates.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<PackageType>Template</PackageType>
<PackageVersion>1.4.1</PackageVersion>
<PackageVersion>1.4.2</PackageVersion>
<PackageId>Keboo.Dotnet.Templates</PackageId>
<Title>Keboo's .NET Templates</Title>
<Authors>Keboo</Authors>
Expand Down
11 changes: 9 additions & 2 deletions templates/WPF/WpfApp/WpfApp/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,23 @@ namespace WpfApp;
public partial class App : Application
{
[STAThread]
public static void Main(string[] args)
private static void Main(string[] args)
{
MainAsync(args).GetAwaiter().GetResult();
}

private static async Task MainAsync(string[] args)
{
using IHost host = CreateHostBuilder(args).Build();
host.Start();
await host.StartAsync().ConfigureAwait(true);

App app = new();
app.InitializeComponent();
app.MainWindow = host.Services.GetRequiredService<MainWindow>();
app.MainWindow.Visibility = Visibility.Visible;
app.Run();

await host.StopAsync().ConfigureAwait(true);
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Expand Down

0 comments on commit c51ee7a

Please sign in to comment.