Time remaining:
"Programming Looping Structures" Please respond to the following:

Computer Science
Tutor: None Selected Time limit: 0 Hours

Looping structures are key design structures use in programming languages.The ability to repeat code is a powerful tool and can save many lines of code.An infinite loop wil use 100% of the CPU.Suggest two(2) action that you can take prevent problem

May 18th, 2015

while(true){//add whatever break condition here}

But this will trash the CPU performance. This execution thread will take as much as possible from CPU's power.

What is the best way to lower the impact on CPU? Adding some Thread.Sleep(n) should do the trick, but setting a high timeout value for Sleep() method may indicate an unresponsive application to the operating system.

Let's say I need to perform a task each minute or so in a console app. I need to keep Main() running in an "infinite loop" while a timer will fire the event that will do the job. I would like to keep Main() with the lowest impact on CPU.

What methods do you suggest. Sleep() can be ok, but as I already mentioned, this might indicate an unresponsive thread to the operating system.


May 18th, 2015

Did you know? You can earn $20 for every friend you invite to Studypool!
Click here to
Refer a Friend
...
May 18th, 2015
...
May 18th, 2015
Dec 9th, 2016
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer