AllExperts > Experts 
Search      

Experts

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More C++ Answers
Question Library

Ask a question about C++
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Ralph McArdell
Expertise
I am a software developer with more than 10 years C++ experience and over 20 years experience developing a wide variety of applications for Windows NT/2000/XP, UNIX, Linux and other platforms. I can help with basic to advanced C++, C, software development and many platform specific and system development problems.

Experience
My career started in the mid 1980s working as a batch process operator for the now defunct Inner London Education Authority, working on Prime mini computers. I then moved into the role of Programmer / Analyst, also on the Primes, then into technical support and finally into the micro computing section, using a variety of 16 and 8 bit machines. Following the demise of the ILEA I worked for a small company, now gone, called Hodos. I worked on a part task train simulator using C and the Intel DVI (Digital Video Interactive) - the hardware based predecessor to Indeo. Other projects included a CGI based train simulator (different goals to the first), and various other projects in C and Visual Basic (er, version 1 that is). When Hodos went into receivership I went freelance and finally managed to start working in C++. I initially had contracts working on train simulators (surprise) and multimedia - I worked on many of the Dorling Kindersley CD-ROM titles and wrote the screensaver games for the Wallace and Gromit Cracking Animator CD. My more recent contracts have been more traditionally IT based, working predominately in C++ on MS Windows NT, 2000. XP, Linux and UN*X. These projects have had wide ranging additional skill sets include system analysis and design, databases and SQL in various guises, C#, client server and remoting, cross porting applications between platforms and various client development processes. On another avenue I have started writing software for Symbian based devices (mobile phones).
 
   

You are here:  Experts > Computing/Technology > C/C++ > C++ > C++ delay a loop or funtion for paticular time delay

Follow-Ups to Answer from Expert Ralph McArdell


Pedro writes on 2006-07-19 15:40:07
Incredible...

Sleep and sleep exist on both unix and Windows OS... So there is no need to reinvent the wheel and to do marvelous things shuch as while(tick() - nStart < nDelay) which consume about 100% cpu cycles during the wait... totally unuseful...

Sleep or sleep is a passive wait call which release your thread/process until the delay has been reached.

On Win32, Sleep is not very accurate when you begin to play with durations around 10-20ms (windows is not real-time os certified), but I have noticed in many projects that WaitForSingleObject(hObject, nDuration) (where hObject is an unused HANDLE (NULL for example) and nDuration is a timeout in ms, is really more accurate than Sleep (or WaitForMultipleObjects...).


Ralpho writes on 2007-02-28 19:28:03
I wrote this answer. If you had read it all you would have noticed that I make this very point.

However functions such as sleep, nanosleep, Sleep and WaitForSingleObject are _not_ part of C++ they are part of the operating system APIs.

Hence I start with the basic and standard then move onto better ways. I accept the point about WaitForSingleObject, however in many cases such accuracy is not required. This is especially true for those just starting to find out that there is a big wide world of operating system API functions out there.



Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.