Udostępnij za pośrednictwem


Debugger2.CurrentProcess Property

Definition

Gets or sets the active process.

public:
 property EnvDTE::Process ^ CurrentProcess { EnvDTE::Process ^ get(); void set(EnvDTE::Process ^ value); };
public:
 property EnvDTE::Process ^ CurrentProcess { EnvDTE::Process ^ get(); void set(EnvDTE::Process ^ value); };
[System.Runtime.InteropServices.DispId(103)]
public EnvDTE.Process CurrentProcess { [System.Runtime.InteropServices.DispId(103)] get; [System.Runtime.InteropServices.DispId(103)] set; }
[<System.Runtime.InteropServices.DispId(103)>]
[<get: System.Runtime.InteropServices.DispId(103)>]
[<set: System.Runtime.InteropServices.DispId(103)>]
member this.CurrentProcess : EnvDTE.Process with get, set
Public Property CurrentProcess As Process

Property Value

A Process object.

Implements

Attributes

Examples

The following example demonstrates how to use the CurrentProcess property.

public static void CurrentProcess(EnvDTE80.DTE2 dte)  
{  
    // 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("Current Process   
    Test");  
    owp.Activate();  

    owp.OutputString("Current Process Info: ");  
    EnvDTE80.Debugger2 debugger = (EnvDTE80.Debugger2)dte.Debugger;  
    EnvDTE80.Process2 process = (EnvDTE80.Process2)debugger.CurrentProcess;  

    if (process == null)  
        owp.OutputString("No process is being debugged");  
    else  
        owp.OutputString("Process ID = " + process.ProcessID +  
                         "  Process Name = " + process.Name);  
}  
Sub ShowCurrentProcess()  
    ' This function displays the current debugger  
    ' mode in the output window.  
    Dim ow As OutputWindow  
    ow = DTE2.Windows.Item(Constants.vsWindowKindOutput).Object  

    Dim proc As EnvDTE.Process2  
    proc = DTE2.Debugger.CurrentProcess  

    If (proc Is Nothing) Then  
        ow.ActivePane.OutputString("No process is being debugged")  
    Else  
        ow.ActivePane.OutputString("" + Str(proc.ProcessID) + ": " + _  
        poc.Name + vbCrLf)  
    End If  
End Sub  

Remarks

The active process is the process that defines the data displayed by the debugger. Although the debugger supports debugging more than one process at a time, only one process can be active at any given time. See Debugging Multiple Programs for more information.

Applies to