Defer the initialization of a VisualStudioWorkspace until necessary
Previously, when a VisualStudioWorkspace was constructed we were doing a bunch of work in the constructor talking to the UI thread. This was dangerous because we might get composed on a background thread. This moves the dangerous initialization until we're creating a project when we know we have a UI thread available. In this refactoring I moved the project tracker and a few other fields into a private class so it's more obvious what's dangerous to touch. I also do a pass through all consumers of the property and either update it to use the deferred state directly (because we're only consuming projects, so it's fine if we don't have anything) or to the factory method if we actually are creating projects. This does temporarily regress the ability to create projects on background threads, but it was unclear if that was generally safe to start with.
Showing
想要评论请 注册 或 登录