다음을 통해 공유


Debugger.RunToCursor(Boolean) Method

Definition

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

void RunToCursor(bool WaitForBreakOrEnd = true);
[System.Runtime.InteropServices.DispId(10)]
public void RunToCursor (bool WaitForBreakOrEnd = true);
[<System.Runtime.InteropServices.DispId(10)>]
abstract member RunToCursor : bool -> unit
Public Sub RunToCursor (Optional WaitForBreakOrEnd As Boolean = true)

Parameters

WaitForBreakOrEnd
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 Stepping for more information.

Attributes

Examples

The following example demonstrates how to use the RunToCursor method.

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  

Remarks

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

Applies to