dotnet / dotnet/wpf

Application hangs on shutdown if a Window was created but never used

Open
#4,204 2 comments 2 reactions 1 assignee Claimed by @h3xds1nz View on GitHub
.NET Framework Bug Investigate
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* .NET Core Version: .net 5.0.3
* Windows version: 20H2 19042
* Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes

**Problem description:**
If you declare a new Window but never use it, the app will hang on shutdown.

**Actual behavior:**

**Expected behavior:**
Application cleanly shuts down.

**Minimal repro:**
1. Create a new blank WPF Application
2. Above the MainWindow constructor, add the following line of code:
`Window window2 = new Window();`
3. Run the application, and shut it down by clicking the "X" button
4. Notice that Visual Studio is still attached to the process and the process is still running (without VS, see in Task Explorer that the process is still running)
5. If `window2` had been opened at some point, the app will cleanly shut down.

List of threads:

![image](https://user-images.githubusercontent.com/1378165/109213530-90392b00-7765-11eb-88b8-7f93627e4ec5.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.