I'm currently porting a VS2010 extension to VS2012 and I've seen that the IVsSolutionEvents.OnAfterOpenProject(IVsHierarchy pHierarchy, int fAdded)
callback is called with fAdded == 1
when I'm loading my solution. I believe this must be due to the asynchronous loading of the projects in VS2012. This doesn't happen with VS2010.
My question is then how can I know in OnAfterOpenProject
that it's being called from the asynchronous project loading process?
(Although late to the party) From MSDN IVsSolutionEvents.OnAfterOpenProject
reference here that behaviour seems correct and the doc explains that (by now, at least):
fAdded
Type: System.Int32
[in] true if the project is added to the solution after the solution is opened. false if the project is added to the solution while the solution is being opened.
And from your report, it seems that false (solution still loading) maps to 1, so I guess true will map to 0. This is somehow consistent with definitions in VSConstants
:
public const int S_FALSE = 1;
public const int S_OK = 0;
Finally, in your OnAfterOpenProject
implementation you can filter calls based on value of that fAdded
input: if invoked with 1, that means that the solution is still (asynchronously) loading, otherwise it means that a new project has been added to a (already loaded) solution.