Debugger3.CurrentProcess 属性

获取或设置活动进程。

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

语法

声明
Property CurrentProcess As Process
Process CurrentProcess { get; set; }
property Process^ CurrentProcess {
    Process^ get ();
    void set (Process^ value);
}
abstract CurrentProcess : Process with get, set
function get CurrentProcess () : Process 
function set CurrentProcess (value : Process)

属性值

类型:Process
一个 Process 对象。

备注

活动进程即定义调试器所显示的数据的进程。 尽管调试器支持同时调试多个进程,但在任意给定时刻只能有一个进程处于活动状态。 有关详细信息,请参阅<PAVEOVER> 调试多个进程

示例

下面的示例演示如何使用 CurrentProcess 属性。

测试此属性:

  1. 打开目标应用程序。 运行外接程序。

    没有任何进程正在调试。

  2. 在目标应用程序中设置一个断点。 以调试模式运行此应用程序。

  3. 当此程序停在该断点处时,运行外接程序。

    正在调试该进程。

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: ");
    EnvDTE90.Debugger3 debugger = (EnvDTE90.Debugger3)dte.Debugger;
    EnvDTE90.Process2 process = (EnvDTE90.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 = dte.Windows.Item(Constants.vsWindowKindOutput).Object

    Dim proc As EnvDTE90.Process3
    proc = dte.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

.NET Framework 安全性

请参阅

参考

Debugger3 接口

EnvDTE90 命名空间