我需要啓動IE並將親和力設置爲特定的單個CPU。 當運行下面的c#代碼時,正如預期的那樣notepad.exe被啓動並且它的親和性被設置爲僅僅cpu2,奇怪的是iexplore.exe的啓動將其親和性設置爲僅僅cpu0。無論我將ProcessorAffinity設置爲iexplore.exe總是轉到cpu0。IEXPLORE.exe奇怪ProcessorAffinity問題
我已經在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
}
}
我放了一個MessageBox.Show(myProcess.ProcessorAffinity.ToString());將親和度從15設置爲4後,msgbox打印4,你期望什麼不起作用? –
您是否嘗試在'launchWithAffinity'方法周圍放置'try catch'來查看是否拋出異常? – Tudor