开发者

Iterating through process names takes AGES

I have a question concerning the Visual Studio COM interface. I use the code below to get all processes on a remote machine and attach to MyExe.exe. The problem is that iterating through the processes' names takes very long. There are only ~20 processes, but the iteration takes ~8 seconds (that means the foreach-loop, not the code before that).

// Get processes
EnvDTE80.Debugger2 debugger2 = (EnvDTE80.Debugger2)dte.Debugger;
EnvDTE80.Transport trans = debugger2.Transports.Item("Default");
processes = debugg开发者_运维问答er2.GetProcesses(trans, remoteName);

// Find exe and attach to it
foreach (EnvDTE.Process proc in processes)
{
  if (proc.Name.Contains("MyExe.exe"))
  {
    proc.Attach();
    break;
  }//end if
}//end foreach

Is that normal? Is there anything I can do to speed things up? Thanks!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜