When breaking an idling Windows Forms app, a WPF app or a Windows Store app into Visual Studio (Debug->Break All) the Threads window shows that it is running on the Main Thread (= UI thread right?). When debugging a click event handler the two first application are still executing on the Main Thread while the Windows Store app is executing on a Worker Thread. Is this thread in fact the UI thread and if so, why is it labeled Worker Thread? And why is there a difference between the two first applications and the Windows Store app, is it to do with ‘everyhing async’ in Windows 8?
Share
Yes, Windows Store apps operate very differently from regular desktop apps. Under the hood they are out-of-process COM servers, a very different activation model from regular Windows EXEs. They are started by the RPCSS service, the startup thread calls RoInitialize() to make itself an MTA thread. WinRT plumbing then creates an STA thread that becomes the home for the UI gadgets and dispatcher loop. Which looks like a worker thread in the debugger.
All of this is very poorly documented, somehow the CLR shoe-horns itself into this activation model. Details that are hidden in the language project built into the CLR and utterly undocumented. You are not supposed to worry about it. Which seems to work, I’ve seen very few questions from programmers fighting the COM threading model.