Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在C#中设置线程,使其仅在CPU空闲时执行?_C#_Windows Services_Cpu Usage - Fatal编程技术网

如何在C#中设置线程,使其仅在CPU空闲时执行?

如何在C#中设置线程,使其仅在CPU空闲时执行?,c#,windows-services,cpu-usage,C#,Windows Services,Cpu Usage,我有一个C#的Windows服务。我希望某个线程执行特定的操作,但仅当CPU空闲时。有没有办法在C#中做到这一点。您可以让操作系统像这样为您处理它: Thread thread = Thread.CurrentThread; thread.Priority = ThreadPriority.Lowest; 尝试将ThreadPriority设置为低于正常值或更低。看

我有一个C#的Windows服务。我希望某个线程执行特定的操作,但仅当CPU空闲时。有没有办法在C#中做到这一点。

您可以让操作系统像这样为您处理它:

Thread thread = Thread.CurrentThread;
thread.Priority = ThreadPriority.Lowest;

尝试将ThreadPriority设置为低于正常值或更低。看