Udostępnij za pośrednictwem


Debugger2.RunToCursor Method

Executes the program to the current position of the source file cursor.

Namespace:  EnvDTE80
Assembly:  EnvDTE80 (in EnvDTE80.dll)

Syntax

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

Parameters

  • WaitForBreakOrEnd
    Type: System.Boolean
    Set to true if this function call should wait until either Break mode or Design mode is entered before returning. Set to false if you want this call to return immediately after causing the debugger to begin execution. Upon return the debugger could be in Design, Break, or Run modes.
    See Code Stepping Overview for more information.

Implements

Debugger.RunToCursor(Boolean)

Remarks

RunToCursor executes the program to the current position of the source file cursor. See How to: Run to a Specified Location for more information.

Examples

The following example demonstrates how to use the RunToCursor method.

To test this method:

  1. Open the target project and run the add-in.
public static void RunToCursor(EnvDTE80.DTE2 dte)
{
    EnvDTE.TextSelection ts = 
    (EnvDTE.TextSelection)dte.ActiveDocument.Selection;
    ts.GotoLine(15, false);
    EnvDTE80.Debugger2 debugger = (EnvDTE80.Debugger2)dte.Debugger;

    debugger.RunToCursor(true);

    // Setup 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 (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.");
}
Sub RunToLine(Optional ByVal line As Integer = -1)
    If line <> -1 Then
        Dim ts As TextSelection
        ts = DTE2.ActiveDocument.Selection
        ts.GotoLine(line)
        DTE2.Debugger.RunToCursor()
    End If
End Sub

.NET Framework Security

See Also

Reference

Debugger2 Interface

EnvDTE80 Namespace