Multi UI thread visit the ContentPresenter at application startup may deadlock
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
* .NET Core Version: All
* Windows version: All
* Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
**Problem description:**
I start the new UI thread in the constructor in App.xaml.cs
And both my Main UI thread and the new UI thread visit the ContentPresenter properties.
The deadlock was found after running the application thousands of times.
**Actual behavior:**
The main UI thread which thread id is 22436 is waiting the static constructor of FrameworkElementFactory.

The new UI thread which thread id is 16100 is waiting the lock which capture by main UI thread.

**Expected behavior:**
It can work well.
**Minimal repro:**
Run my demo thousands of times and you can see that the application is hangs
https://github.com/lindexi/lindexi_gd/tree/de8bdfbf4715c7200631913cecd24749c98228a3/BerehenachearbairGarciwereyer
Contributor guide
Assessment
This issue has not been assessed yet.