Я успешно создаю Visual Studio с помощью следующего кода:
System.Type t = System.Type.GetTypeFromProgID("VisualStudio.DTE.9.0");
object obj = Activator.CreateInstance(t, true);
dte = (DTE)obj;
Solution sln = dte.Solution;
sln.Open(SolutionFile);
System.Threading.Thread.Sleep(1000);
//Do stuff with the solution
Обратите внимание на вызов Thread.Sleep(1000)
? Если я не включаю это, код пытается обнулить экземпляр перед его готовкой, и я получаю исключение:
the message filter indicated that the application is busy.
Вместо того, чтобы ждать ровно n секунд, существует ли способ опроса этого объекта для готовности?