Click here to Skip to main content
15,917,702 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionFont Information Pin
Gupta Suraj14-Nov-06 8:09
Gupta Suraj14-Nov-06 8:09 
AnswerRe: Font Information Pin
Rajesh R Subramanian15-Nov-06 0:48
professionalRajesh R Subramanian15-Nov-06 0:48 
Questionhyperthreading a driver Pin
vineeshV14-Nov-06 7:06
vineeshV14-Nov-06 7:06 
Questionuser groups Pin
EpicYeti14-Nov-06 6:39
EpicYeti14-Nov-06 6:39 
AnswerRe: user groups Pin
David Crow14-Nov-06 6:47
David Crow14-Nov-06 6:47 
GeneralRe: user groups Pin
EpicYeti14-Nov-06 6:55
EpicYeti14-Nov-06 6:55 
AnswerRe: user groups Pin
Hamid_RT14-Nov-06 19:14
Hamid_RT14-Nov-06 19:14 
QuestionCPU Usage - 100% Pin
Programm3r14-Nov-06 6:21
Programm3r14-Nov-06 6:21 
Hi all,

I have a loop in my program, that is waiting for a client to connect via TCP/IP for example:
But the thing is, the application uses the cpu to the max (waiting for a client(s)).

<br />
 printf("Waiting for client (press any key to abort)...\n");<br />
 while(1)<br />
 {<br />
	 if(kbhit())<br />
	 {<br />
		 exit(1);<br />
		 break;<br />
	 }<br />
 .... // lots of code follows<br />
 }<br />


My question is, is there another way of running a loop so that it will use less cpu uasge?

Thanx in advance

The only programmers that are better than C programmers are those who code in 1's and 0's..... Smile | :)

Smile | :) Programm3r

AnswerRe: CPU Usage - 100% Pin
Anthony Mushrow14-Nov-06 6:34
professionalAnthony Mushrow14-Nov-06 6:34 
GeneralRe: CPU Usage - 100% Pin
Programm3r14-Nov-06 6:48
Programm3r14-Nov-06 6:48 
GeneralRe: CPU Usage - 100% Pin
Zac Howland14-Nov-06 10:18
Zac Howland14-Nov-06 10:18 
QuestionRe: CPU Usage - 100% Pin
Programm3r14-Nov-06 18:26
Programm3r14-Nov-06 18:26 
AnswerRe: CPU Usage - 100% Pin
Zac Howland15-Nov-06 4:57
Zac Howland15-Nov-06 4:57 
QuestionRe: CPU Usage - 100% Pin
Programm3r14-Nov-06 18:45
Programm3r14-Nov-06 18:45 
AnswerRe: CPU Usage - 100% Pin
Zac Howland15-Nov-06 5:01
Zac Howland15-Nov-06 5:01 
AnswerRe: CPU Usage - 100% Pin
Mark Salsbery14-Nov-06 6:43
Mark Salsbery14-Nov-06 6:43 
GeneralRe: CPU Usage - 100% Pin
Programm3r14-Nov-06 6:51
Programm3r14-Nov-06 6:51 
GeneralRe: CPU Usage - 100% Pin
Mark Salsbery14-Nov-06 6:54
Mark Salsbery14-Nov-06 6:54 
GeneralRe: CPU Usage - 100% Pin
Programm3r14-Nov-06 6:57
Programm3r14-Nov-06 6:57 
QuestionRe: CPU Usage - 100% Pin
David Crow14-Nov-06 6:51
David Crow14-Nov-06 6:51 
AnswerRe: CPU Usage - 100% Pin
Programm3r14-Nov-06 6:54
Programm3r14-Nov-06 6:54 
GeneralRe: CPU Usage - 100% Pin
Programm3r14-Nov-06 7:52
Programm3r14-Nov-06 7:52 
QuestionGetline() in thread Pin
Max++14-Nov-06 4:58
Max++14-Nov-06 4:58 
AnswerRe: Getline() in thread Pin
Cedric Moonen14-Nov-06 5:05
Cedric Moonen14-Nov-06 5:05 
AnswerRe: Getline() in thread Pin
Viorel.14-Nov-06 5:12
Viorel.14-Nov-06 5:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.