关于c#多线程对特定cpu的操作

猫de天空之城 2013-02-01 08:27:33
这些天在看《编程之美》,谈到一个使cpu占有率固定在某个值。都实现了书上方法后,还有一个使双核cpu的占有率是2个不同的函数,一直没实现,网上有人完成的是cpp版的,c#版我自己用线程写,发现我自己只能用进程对特定cpu操作,无法用线程操作,我想问下有木有线程操作的函数(就是能让某个线程跑在指定cpu上),菜鸟谢谢了
...全文
624 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yangguosheng 2014-11-08
  • 打赏
  • 举报
回复
引用 3 楼 CandPointer 的回复:

ProcessThread Properties
IdealProcessor 	      Sets the preferred processor for this thread to run on.
ProcessorAffinity 	Sets the processors on which the associated thread can run.
怎么得到ProcessThread 对象呢???
yangguosheng 2014-11-06
  • 打赏
  • 举报
回复

ProcessThread Properties
IdealProcessor 	      Sets the preferred processor for this thread to run on.
ProcessorAffinity 	Sets the processors on which the associated thread can run.
[/quote] 怎么得到 ProcessThread 操作系统进程线程
猫de天空之城 2013-02-06
  • 打赏
  • 举报
回复
引用 3 楼 CandPointer 的回复:
C/C++ code?1234DWORD_PTR WINAPI SetThreadAffinityMask( _In_ HANDLE hThread, _In_ DWORD_PTR dwThreadAffinityMask); C# code?123ProcessThread PropertiesIdealProcessor Sets……
能给个样例吗?我看了msdn的样例没看懂。。。菜鸟
CandPointer 2013-02-03
  • 打赏
  • 举报
回复

DWORD_PTR WINAPI SetThreadAffinityMask(
  _In_  HANDLE hThread,
  _In_  DWORD_PTR dwThreadAffinityMask
);


ProcessThread Properties
IdealProcessor 	      Sets the preferred processor for this thread to run on.
ProcessorAffinity 	Sets the processors on which the associated thread can run.
猫de天空之城 2013-02-03
  • 打赏
  • 举报
回复
求路过大神指点迷津啊
猫de天空之城 2013-02-01
  • 打赏
  • 举报
回复
怎么人都木有,不科学啊

111,094

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧