设置进程的优先级,把它从Normal降低到Idle,精确控制范围可能不行,但在CPU空闲时再运行应该没问题ITask::SetPriority The SetPriority method sets the priority for the task.HRESULT SetPriority( DWORD dwPriority ); Parameters dwPriority [in] A DWORD that specifies the priority for the current task. The priority of a task determines the frequency and length of the time slices for a process. This applies only to Windows NT/Windows 2000 and has no effect in Windows 95. These values are taken from the CreateProcess priority class and can be one of following flags (in descending order of thread scheduling priority): REALTIME_PRIORITY_CLASS HIGH_PRIORITY_CLASS NORMAL_PRIORITY_CLASS IDLE_PRIORITY_CLASS
{
if(PeekMessage() )
{
TranslateMessage();
DispatchMessage();
}
else
{
工作
}
}
刚开始搜索并写入数据库的时候cpu利用率很高
我就想能不能限制下
在一定的cpu利用率范围内运行??????
The SetPriority method sets the priority for the task.HRESULT SetPriority(
DWORD dwPriority
);
Parameters
dwPriority
[in] A DWORD that specifies the priority for the current task. The priority of a task determines the frequency and length of the time slices for a process. This applies only to Windows NT/Windows 2000 and has no effect in Windows 95. These values are taken from the CreateProcess priority class and can be one of following flags (in descending order of thread scheduling priority):
REALTIME_PRIORITY_CLASS
HIGH_PRIORITY_CLASS
NORMAL_PRIORITY_CLASS
IDLE_PRIORITY_CLASS
应该改成IDLE吧
谢谢大家