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); }
public void UpdateVSProcesses() { vsProcesses.Clear(); VSFinder.GetAllRunningInstances(ref vsProcesses); }