dotnet / dotnet/wpf

WPF multi-thread UI is not thread-safe

Open
#8,764 6 comments 0 reactions 0 assignees View on GitHub
Needs minimal repro project
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

_This issue has been moved from [a ticket on Developer Community](https://developercommunity.visualstudio.com/t/WPF-multi-thread-UI-is-not-thread-safe-/10531948)._

---
\[severity:It bothers me. A fix would be nice\]
Hello,

We have WPF project where there are a 3 UI windows, each one runs on its own UI thread.
On project startup, the threads are created and by the way the 3 windows are created in parallel.

We noticed that the method **InitializeComponent()** is not thread-safe and causes an exception in the method **CleanUpRequestedStreamList()** within the file **PakageParts.cs**

In the following screenshot, we see that **\_requestedStreams.Count = 1** so the variable **i** should start from **0** but its value is **1** which means another thread modified it.

![Bab6ec1230460465fb65c2a7709542095638370603241413162_20231201-154523-image](https://github.com/dotnet/wpf/assets/105205215/71b0077e-5180-42bc-975d-e3530fe3a231)

Is there any possibility to support multi-threaded UI in Wpf?

Thanks!

---
### Original Comments

#### Feedback Bot on 12/4/2023, 07:18 AM:

(private comment, text removed)

---
### Original Solutions
(no solutions)

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.