7

I've been using the Concurrency Visualizer tool in Visual Studio to get an understanding of the threading in a WPF project I'm working on. The application isn't heavily multi-threaded, all multi-threading is just to avoid blocking the UI Thread. When I ran the Concurrency Visualizer I was very surprised to see approximately 50+ threads! To make things more confusing, almost all of those 50+ threads, spent their entire time in "Synchronization", which is "blocked" as far as I understand.

As an experiment I created a new blank WPF Application project, and ran it with the Concurrency Visualizer, again to my surprise, an application that I expected to have a single main thread, and maybe one or two more for garbage collection or other CLR stuff, turns out to have 10 threads!

Screenshot of Concurrency Visualizer showing 10 threads in a simple WPF Application

So my questions are:

  1. Why are there so many threads in a very simple application?
  2. Generally speaking what are the functions of these threads?
  3. Why are they spending almost all their time "Synchronization"?
  4. Any recommendations for a book/website that covers this topic?
0

1 Answer 1

1

There is a good answer for that question here, by Jerry Bullard: 19 Threads for WPF Application

So, besides of WPF UI and rendering threads, there are different types of .NET threads: finalizer, GC, debugger, timer, threadpool, primary and background threads. Threadpool have minimum of two threads. This all gives us a minimum of 10 threads (just like in your screenshoot).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.