SetProcessorAffinity 给我带来了问题
好吧,我正在尝试部署我的第一个使用多线程的 Xbox 360 XNA 游戏,并且我正在尝试使用 Thread.CurrentThread.SetProcessorAffinity() 函数将一个线程放在另一个硬件线程上,例如所以:
#if XBOX360
Thread.CurrentThread.SetProcessorAffinity(new int[] { xbox360UpdateThread });
Thread.CurrentThread.IsBackground = true;
#endif
我也尝试过这个:
#if XBOX
Thread.CurrentThread.SetProcessorAffinity(new int[] { xbox360UpdateThread });
Thread.CurrentThread.IsBackground = true;
#endif
编译器给我上面第一条指令中的括号带来的问题..在VS2008中,所有括号都用红色标记加下划线,我得到以下错误:
error CS1519: Invalid token '(' in class, struct, or interface member declaration
error CS1519: Invalid token '{' in class, struct, or interface member declaration
error CS1519: Invalid token '}' in class, struct, or interface member declaration
error CS0116: A namespace does not directly contain members such as fields or methods
如果我隐藏整个线程上面的指令,我在 Xbox 360 上编译并运行我的游戏..只有这个线程指令导致了问题..
有人知道我做错了什么吗?我使用的是 XNA 3.1,而不是 4.0 ..
Well I'm trying to deploy my first ever Xbox 360 XNA game which uses multithreading, and I'm trying to put a thread on another hardware thread using the Thread.CurrentThread.SetProcessorAffinity()
function, like so:
#if XBOX360
Thread.CurrentThread.SetProcessorAffinity(new int[] { xbox360UpdateThread });
Thread.CurrentThread.IsBackground = true;
#endif
I have also tried this:
#if XBOX
Thread.CurrentThread.SetProcessorAffinity(new int[] { xbox360UpdateThread });
Thread.CurrentThread.IsBackground = true;
#endif
The compiler is giving me problem with the brackets somewhere in the first instruction above .. In VS2008, all the brackets are underlined with those red markers and I get the following errors:
error CS1519: Invalid token '(' in class, struct, or interface member declaration
error CS1519: Invalid token '{' in class, struct, or interface member declaration
error CS1519: Invalid token '}' in class, struct, or interface member declaration
error CS0116: A namespace does not directly contain members such as fields or methods
if I hide the entire threading directive above, and I compile and run my game on the Xbox 360 .. Only this threading directive is causing a problem ..
Anyone know what am I doing wrong ? I'm using XNA 3.1, not 4.0 ..
我会做以下事情:
I would do the following: