【发布时间】:2016-01-23 17:55:23
【问题描述】:
我正在尝试在 c++ 中实现 htop(系统监控)。
所以我正在使用 ncurses 来刷新我的终端。
例如,我需要每 5 秒获取一次新信息,我使用循环来执行此操作。
while (42)
{
key = std::cin.get();
std::cout << key;
this->gereEvent(key);
std::cout << i<< std::endl;
if (i == 500000000)
{
std::cout << "test"<< std::endl;
// fputs(tgetstr((char *)"cl", 0), stdout);
this->refresh();
i = 0;
}
i++;
}
但问题是 cin.get() 停止循环.. 我也不能做线程,因为 std::thread 需要 c++11。
你知道我该怎么做吗?
【问题讨论】: