我需要启动IE并将亲和力设置为特定的单个CPU。 运行以下c#代码时,正如预期的那样启动notepad.exe并将其亲和性设置为cpu2,奇怪的是iexplore.exe启动时其亲和性设置为cpu0。无论我将ProcessorAffinity设置为iexplore.exe总是转到cpu0。
我已经在4核xp 32位和4核2008 64位上测试过这两款IE8。
using System;
using System.Diagnostics;
public class Launch
{
public static void Main(string[] args)
{
lauchWithAffinity("c:/windows/system32/notepad.exe");
lauchWithAffinity("c:/Program Files/Internet Explorer/IEXPLORE.EXE");
}
static void lauchWithAffinity(string exePath)
{
ProcessStartInfo start = new ProcessStartInfo();
start.FileName = exePath;
Process myProcess =Process.Start(start);
myProcess.ProcessorAffinity = (System.IntPtr)4; //3rd cpu aka cpu2
//http://msdn.microsoft.com/en-us/library/system.diagnostics.process.processoraffinity.aspx
}
}
答案 0 :(得分:0)
我测试了你的程序,它对我来说很好。我甚至检查了任务管理器,iexplore.exe
的亲和力设置为CPU 2。