Search code examples
visual-studio-2010visual-studiovisual-studio-2008visual-studio-extensionsenvdte

Visual Studio Extension: Wait for all projects to complete loading with IVsSolutionEvents OnAfterOpenSolution


I am looking for an event/interface to use that notifies me once all projects have loaded in a solution after opening a solution.

I have implemented OnAfterOpenSolution in IVsSolutionEvents2 interface. This gets called immediately after the solution opens... so any code I run against the UI thread, even asycnhronously, locks up the IDE prior to the project(s) loading.

Is there a similar technique to implementing `OnAfterOpenSolution', that is called once all the projects for the solution have opened?


Solution

  • The OnAfterBackgroundSolutionLoadComplete event in the IVsSolutionLoadEvents interface is fired after all projects for the solution have completed loading. The implementation for this will still need to implement or extend from an implementation of one of the IVsSolutionEvents interfaces in order to attach the event using IVsSolution.AdviseSolutionEvents(..) method.

    Upon Further investigation in this area, the OnAfterBackgroundSolutionLoadComplete only occurs if projects are set to load in the background. If the background loading has been disabled this event will not occur. You will likely also have to implement IVsSolutionLoadManager and ensure that at least 1 project has a background load priority if you intend to rely on the OnAfterBackgroundSolutionLoadComplete event, or switch based on how the user has set their loading priority.