如题

解决方案 »

  1.   

    while(TRUE)
    {
        if(PeekMessage() )
         {
           TranslateMessage();
           DispatchMessage();
         }
         else
         {
            工作
         }
    }
      

  2.   

    这个函数应该可以CWinApp::OnIdle
      

  3.   

    我做了个小程序搜索本地文件
    刚开始搜索并写入数据库的时候cpu利用率很高
    我就想能不能限制下
    在一定的cpu利用率范围内运行??????
      

  4.   

    设置进程的优先级,把它从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 
      

  5.   

    楼上说的很对 我设置的是lowest
    应该改成IDLE吧 
    谢谢大家