I'm looking to understand the thread usage in various types of applications and I'm a bit surprised that WPF apps have 2 more threads (besides the UI thread) that I didn't expect.
I followed these steps:
F5
to start it in debug modeDebug -> Windows -> Parallel Stacks
Break All
buttonParallel Stacks
windowI expected to get a single thread - the UI thread, but got 3 threads instead:
The leftmost thread is the UI thread - which I expected all along, but what are the other 2 threads used for? I didn't create them - I just made a barebones WPF app - no modifications to the initial code generated by the new project wizard.
Also how do I use the functions indicated with red arrows in the screenshot above:
ProtocolHandler.SendThread
ProtocolHandler.ReadThread
I looked for the documentation, but didn't find much info on these. I also tried to use them in the code behind, but there are no using statements to add - they are just unrecognized.
The full namespace of the ProtocolHandler
class is Microsoft.VisualStudio.DesignTools.WpfTap.Networking
. As the name indicates, it's used by the design debugging tools from Visual Studio (likely the one that allows to inspect/modify the UI at runtime).
If you disable those tools in Visual Studio (Tools -> Options -> Debugging -> Uncheck "Enable UI Debugging Tools for XAML"), you'll see that the two extra threads won't be started anymore.