宏如何等待执行命令的完成? [英] how can macro wait for the finish of executecommand?
问题描述
I have a solution which contains over 100 projects Main()
Goal: iterate all the projects, if satisfy certain condition, link the project.(just like right-click a project form solution explore->project only->link only project)
Attention: I do not want to use build as DTE.Solution.SolutionBuild.Build(True) can do.
Problem: when call Sleep() to wait for the result of ExecuteCommand, it seems VS also being hanged and didn't effectively execute the command I send from macro.
Following is the code:
Sub
尝试
昏暗 项目 As
.DTE.ExecuteCommand( " Build.Link"" done = Sleep(1000)
结束 完成= 假
下一个
渔获 As 异常
target.OutputStr ing( 原因如下:{0}" ,例如e.Message)
结束 结束 模块 EnvironmentEvents
Public doneProj 如 收藏= 新 收藏集
Private BuildEvents_OnBuildProjConfigDone( ByVal , ByVal String ,_
="font-size:x-small; color:#0000ff"> As , ByVal SolutionConfig As ,_
="font-size:x-small; color:#0000ff"> As ) 句柄 BuildEvents.OnBuildProjConfigDone
完成= True
doneProj.Add(Project)
结束 模块
Main()
Try
Dim proj As Project
For Each proj In DTE.Solution.Projects
DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate()
Dim projName = GetSolutionName(DTE.Solution.FullName) + "\" + proj.Name
DTE.ActiveWindow.Object.GetItem(projName).Select(vsUISelectionType.vsUISelectionTypeSelect)
DTE.ExecuteCommand("Build.Link")
While done = False
Sleep(1000)
End While
done = False
Next
Catch e As Exception
target.OutputString("Operation failed for the following reason: {0}", e.Message)
End Try
End Sub
Public Module EnvironmentEvents
Public done As Boolean
Public doneProj As Collection = New Collection
Private Sub BuildEvents_OnBuildProjConfigDone(ByVal Project As String, ByVal ProjectConfig As String, _
ByVal Platform As String, ByVal SolutionConfig As String, _
ByVal Success As Boolean) Handles BuildEvents.OnBuildProjConfigDone
done = True
doneProj.Add(Project)
End Sub
End Module
推荐答案
有帮助吗?
我用另一种方式描述了我的问题.
我想自动重新-link(仅链接,不生成)在解决方案中的所有选定项目.
任何线索都值得赞赏.
Any help?
I describe my problem from another way.
I want to automaticly re-link(only link, not build) all selected projects in a solution. how to implement it?
any clue is appreciated.
这篇关于宏如何等待执行命令的完成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!