SetProcessorAffinity 给我带来了问题

发布于 2024-10-06 09:27:11 字数 1030 浏览 0 评论 0原文

好吧,我正在尝试部署我的第一个使用多线程的 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 ..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷你仙 2024-10-13 09:27:11

我会做以下事情:

#if XBOX360 
    // We can not use threads 0 or 2   
    int[] xbox360UpdateThread = new int[] { 4 }; 
    Thread.CurrentThread.SetProcessorAffinity(xbox360UpdateThread); 
    Thread.CurrentThread.IsBackground = true; 
#endif 

I would do the following:

#if XBOX360 
    // We can not use threads 0 or 2   
    int[] xbox360UpdateThread = new int[] { 4 }; 
    Thread.CurrentThread.SetProcessorAffinity(xbox360UpdateThread); 
    Thread.CurrentThread.IsBackground = true; 
#endif 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文