Table of Contents
CSleep
CSleep is a C++ class for sleep functions. To have a small delay repeatedly this can be more efficient than using SleepMilliseconds because it does not have to pass the parameter and evaluate the amount of time to delay each time.
Constructor
CSleep(int nSeconds, int nMilliseconds);
Parameters
- nSeconds - Number of seconds to sleep when 'Pause' member function is called
- nMilliseconds - Number of milliseconds to sleep when 'Pause' member function is called
Example
CSleep slp(0, 50); int n; for(n = 0; n < 10; n++) { printf("Item %d\r\n", n); slp.Pause(); // This will create a 50 millisecond delay between each iteration in the loop }
Member Functions
SetTime
Sets the pause time
void SetTime(int nSeconds, int nMilliseconds);
Parameters
- nSeconds - Number of seconds to sleep when 'Pause' member function is called
- nMilliseconds - Number of milliseconds to sleep when 'Pause' member function is called
Return Value
Function does not return a value.
Remarks
Example
CSleep slp(0, 50); int n; for(n = 0; n < 10; n++) { printf("Item %d\r\n", n); slp.Pause(); // This will create a 50 millisecond delay between each iteration in the loop } // Now we might want to reuse the same object with a different delay slp.SetTime(0, 100); for(n = 0; n < 10; n++) { printf("Item %d\r\n", n); slp.Pause(); // This will create a 100 millisecond delay between each iteration in the loop }
Pause
Pauses the amount of time specified by the constructor or SetTime
void Pause(void);
Parameters
Function does not accept any parameters
Retrun Value
Function does not return any result.
Remarks
Example
CSleep slp(0, 50); int n; for(n = 0; n < 10; n++) { printf("Item %d\r\n", n); slp.Pause(); // This will create a 50 millisecond delay between each iteration in the loop }
Last modified
14 years ago
Last modified on 08/26/10 12:46:53
Note:
See TracWiki
for help on using the wiki.