Visual Studio add-in: how to find out when a solution has finished loading

I am writing a VS2008 add-in (using DTE) that should be notified after the current solution has finished loading.

I tried using the following code:

events = (Events2) applicationObject.Events
events.SolutionEvents.Opened += DoSomeWorkEvent;

Unfortunately, it seems that after VS2005 the event is fired when the solution starts loading, and not when it ends.

A short search on the Internet triggered the following thread , which explains the problem and offers a solution (check each element of the project to see if the download has finished).

Is this the best solution or is there a better way to find out when the solution finished loading?

+3
source share
1

, - Windows.Forms.Timer, , .

private void TimerTick(object sender, EventArgs e)
{
   try
   {
       var solution = applicationObject.Solution;
       if (solution.IsOpen && string.IsNullOrEmpty(solution.FileName) == false)
       {
           timer.Stop();
           // insert logic here
       }
   }
   catch (Exception exception)
   {
       Console.WriteLine(exception);
   }
}
+4

Source: https://habr.com/ru/post/1718880/


All Articles