我正在尝试部署我的第一个使用多线程的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 ..
答案 0 :(得分:2)
我会做以下事情:
#if XBOX360
// We can not use threads 0 or 2
int[] xbox360UpdateThread = new int[] { 4 };
Thread.CurrentThread.SetProcessorAffinity(xbox360UpdateThread);
Thread.CurrentThread.IsBackground = true;
#endif