Debugger.RunToCursor 方法

将程序执行到源文件光标的当前位置。

命名空间:  EnvDTE
程序集:  EnvDTE(在 EnvDTE.dll 中)

语法

声明
Sub RunToCursor ( _
    WaitForBreakOrEnd As Boolean _
)
void RunToCursor(
    bool WaitForBreakOrEnd
)
void RunToCursor(
    [InAttribute] bool WaitForBreakOrEnd
)
abstract RunToCursor : 
        WaitForBreakOrEnd:bool -> unit
function RunToCursor(
    WaitForBreakOrEnd : boolean
)

参数

  • WaitForBreakOrEnd
    类型:Boolean

    如果此函数调用应等待至进入中断模式或设计模式后才返回,则设置为 true。 如果希望此调用在导致调试器开始执行之后立刻返回,则设置为 false。 返回时,调试器可以为设计、中断或运行模式。

    有关更多信息,请参见单步执行。

备注

RunToCursor 执行程序直至源文件光标的当前位置。 有关更多信息,请参见<PAVEOVER> 如何:运行到指定位置

示例

下面的示例演示如何使用 RunToCursor 方法。

若要测试此方法,请执行下列操作:

  1. 打开目标项目并运行外接程序。
public static void RunToCursor(DTE dte)
{
    EnvDTE.TextSelection ts = (EnvDTE.TextSelection)dte.ActiveDocument.Selection;
    ts.GotoLine(15, false);
    dte.Debugger.RunToCursor(true);

    // Setup the debug Output window.
    Window w = (Window)dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);
    w.Visible = true;
    OutputWindow ow = (OutputWindow)w.Object;
    OutputWindowPane owp = ow.OutputWindowPanes.Add("RunToCursor Method Test");
    owp.Activate();
    if(dte.Debugger.CurrentProgram.IsBeingDebugged)
        owp.OutputString("This program is being debugged and " + 
                         "the cursor is on line: " + ts.CurrentLine);
    else
        owp.OutputString("This program is not being debugged.");
}
Shared Sub RunToCursor(ByRef dte As EnvDTE.DTE)
    Dim ts As EnvDTE.TextSelection = dte.ActiveDocument.Selection
    ts.GotoLine(15, False)
    dte.Debugger.RunToCursor(True)
    If dte.Debugger.CurrentProgram.IsBeingDebugged Then
        MessageBox.Show("This program is being debugged and the cursor is on line: " + ts.CurrentLine.ToString(), _
                        "Debugger Test - RunToCursor Test")
    Else
        MessageBox.Show("This program is not being debugged.", _
                        "Debugger Test - RunToCursor Test")
    End If
End Sub

.NET Framework 安全性

请参阅

参考

Debugger 接口

EnvDTE 命名空间