简体   繁体   English

VB.net流程亲和力

[英]VB.net Process Affinity

Goal: My goal is to set all running processes's affinity to 1 core. 目标:我的目标是将所有正在运行的进程的关联性设置为1个核心。 Then launch a program with the affinity of all the cores. 然后启动具有所有核心相似性的程序。

Skill Lvl: My skill level in programming in general is pretty much beginner. 技能水平我一般的编程技能水平几乎是初学者。 This is my first language. 这是我的母语。

Need: I would like some help with this coding and maybe an article or description of the code. 需求:我希望获得有关此编码的帮助,也许还需要有关该编码的文章或说明。 Thank you 谢谢

There is a C# solution here . 有一个C#解决方案在这里

In summary, you need to loop through all processes ( Process.GetProcesses ) and set their .ProcessorAffinity to New IntPtr(1) , then start your new process. 总而言之,您需要遍历所有进程( Process.GetProcesses )并将它们的.ProcessorAffinity设置为New IntPtr(1) ,然后启动新进程。 (The default is already to use all cores, but for completeness, if you want the new process to have a different affinity, set it after it's been started the same way as above.) (默认情况下已经使用所有内核,但是为了完整起见,如果您希望新进程具有不同的相似性,请按照与上述相同的方式在启动后进行设置。)

All the code: 所有代码:

Dim procs = Process.GetProcesses
For Each p In procs
 p.ProcessorAffinity = New IntPtr(1)
Next
Dim myProc = Process.Start("notepad.exe")
' Stop here to answer the OP.
' This sets the new Notepad process to be the only process running on the second CPU:
myProc.ProcessorAffinity = New IntPtr(2)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM