Ejemplo n.º 1
0
        public static VSProcess StartNewProcess()
        {
            var process = System.Diagnostics.Process.Start("devenv.exe");

            if (process != null && !process.HasExited)
            {
                //Trick: Wait until process initialized, which happens to be when the window title was given
                //Also, VS seems to give "Visual Studio" once project was loaded so wait for that too..
                int tries = 0;
                while (tries <= MaxInstanceStartRetries &&
                       !process.HasExited && (string.IsNullOrEmpty(process.MainWindowTitle) || !process.MainWindowTitle.EndsWith("Visual Studio")))
                {
                    tries++;
                    System.Threading.Thread.Sleep(InstanceStartRetryTimeout);
                    process.Refresh();
                }

                // Magic value for sleeping before we can hook into the DTE
                System.Threading.Thread.Sleep(1000);
                return(VSFinder.GetInstanceByProcessId(process.Id));
            }

            return(null);
        }
Ejemplo n.º 2
0
 public void UpdateVSProcesses()
 {
     vsProcesses.Clear();
     VSFinder.GetAllRunningInstances(ref vsProcesses);
 }