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

/ 6评论 / 835阅读 / 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. bHeSgnPU说道:

    Abbreviations IM, intramuscularly; IV, intravenously emla cream and priligy tablets 84 Transcription factor AP 2Оі activating enhancer binding protein 2Оі Cell cycle growth proliferation EMP3 NM_001425 1

  2. Grofask说道:

    There hypertension list of medications in alphabetical order pdf is no concept of time in another world, and she doesn t quite understand why in that colorful world, all apple cider vinegar pills blood pressure the people are in such a hurry propecia 5mg

  3. Authelm说道:

    Hong et al Protective effects of the pyrolyzates derived from bamboo against neuronal damage and hematoaggregation order cialis 10 mmol was dissolved in THF 2

  4. 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

  5. VORVOSESK说道:

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

  6. 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

发表回复

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