views:

145

answers:

2

Hello,

I am trying to write a macro for Building my application, kicking off an external tool, and ataching the debugger to that external tool.

Everything is working except for the building. It builds, but it is not blocking the thread so the external tool gets kicked off before it can finish. Is there a way I can run ExecuteCommand and wait for the thread to finish?

Code is below:

    DTE.ExecuteCommand("ClassViewContextMenus.ClassViewProject.Build")
    DTE.ExecuteCommand("Tools.ExternalCommand11")

    Try
        Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger
        Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")
        Dim dbgeng(1) As EnvDTE80.Engine
        dbgeng(0) = trans.Engines.Item("Managed")
        Dim proc2 As EnvDTE80.Process2 = dbg2.GetProcesses(trans, "MINIPC").Item("_nStep.exe")
        proc2.Attach2(dbgeng)
    Catch ex As System.Exception
        MsgBox(ex.Message)
    End Try
A: 

This was answered on this thread I believe:

http://stackoverflow.com/questions/841725/run-visual-studio-2008-macro-on-pre-build-event

Chance
A: 

If you attach the debugger to the first process, ClassViewContextMenus.ClassViewProject.Build, as well as the second then presumably the host process would block until the first process is complete. Alternatively get hold of the process handle for the first process in some other way and wait for it to exit. Given the clever debugger stuff you are doing I assume you would know how to do this better than I.

mikemay