C Main Loop without 100% cpu

前端 未结 11 2321
半阙折子戏
半阙折子戏 2020-12-14 08:53
#include 

int main() {
  while(!DONE) {
    /* check for stuff */
  }
  return 0;
}

The above code sample uses 100% cpu until DONE

11条回答
  •  自闭症患者
    2020-12-14 09:22

    If I'm guessing correctly (I don't know about it), the equivalent of App.ProcessMessages is doing blocking IO. And as I don't know of any implementation of C on multitasking OS which uses polling, any standard C IO should be safe.

提交回复
热议问题