是否可以在后台执行C#程序 [英] Is it possible to execute c# program in background
问题描述
我正在用C#(VS 2002)编写模拟,初步估计表明该程序将运行3-4周.当原型运行时,它将占用超过99%的CPU.我希望在可能的情况下进行仿真,以便在使用PC时使用有限的CPU资源,并在不使用PC时接管所有可用资源.我有什么选择?
I am writing a simulation in C# (VS 2002) preliminary estimates show that the program will run for 3-4 weeks. When the prototype runs it takes over 99% of the CPU. I would like if possible for the simulation to use limited CPU resources when the PC is in use and take over all the available resources when I am not using the PC. What are my options?
谢谢
Alex
推荐答案
您可以尝试降低进程和线程的优先级.您可能仍然会遇到其他资源(例如磁盘IO)的争用.其他一些选项是:
You can try lowering the process and thread priority. You may still encounter contention for other resources (e.g., disk IO). Some other options are:
-检测用户输入的空闲时间以进行节气门处理.我认为Windows消息处理为此提供了一个钩子.
- Detect user input idle period to throttle processing. Windows message processing provide a hook for this, I think.
-实施为屏幕保护程序(对此不太熟悉)
- Implement it as a screen saver (not too familiar with this)
这篇关于是否可以在后台执行C#程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!