[c/c++]在使用循环去查询消息等操作时加入Sleep()

/ 3评论 / 634阅读 / 0点赞

加入比较短时间的Sleep()一般对时效性影响不大,但能极大地降低CPU占用。

#include<conio.h>
#include<iostream>
#include<windows.h>
using namespace std;

int main()
{
	cout << "<< 按任意键继续... ";
	for (int i = 0; _kbhit() == 0;)	//等待按键
	{
		switch (i++)	//选择打印最后的一个字符,使之有动画效果
		{
		case 0:cout << "\b/"; break;
		case 1:cout << "\b-"; break;
		case 2:cout << "\b\\"; break;
		case 3:
		{
			cout << "\b|";
			i = 0;
		}break;
		}
		//Sleep(100);    //暂停100毫秒(1秒 = 1000毫秒)
	}
}
  1. VORVOSESK说道:

    site combien d urine en 24h correction presbytie lentilles maladie dГ©gГ©nГ©rative des muscles anatomie petit bassin operation de l urГЁtre svt terminale s gГ©nГ©tique anatomie de la racine des plantes philip stubbes anatomie of abuses yeux de deux couleurs diffГ©rentes buy generic lasix online

  2. VORVOSESK说道:

    nolvadex Given the clinical significance of this we suggest to further review the value of ID interventions on PAB in a prospective study

  3. VORVOSESK说道:

    Average lifetime manure production was estimated at 11, 1287, and 20, 300 lb animal for poultry, swine, and beef cattle, respectively 80 buy cialis online Moreover, functional studies indicate that decidual angiogenesis is mainly regulated by vascular endothelial growth factor A VEGF- A secreted from decidual stromal cells expressing PR; thus, greater expression of VEGF- A corresponds to high PR expression

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注