|
-
October 30th, 2002, 10:30 AM
#1
a problem
hello
is it possible in c++ after a certain time the input is over
i,e when user does not any thing for specified time the massage be displayed "Time is over"
-
October 30th, 2002, 02:42 PM
#2
Yes. Your problem is a related to design, not implementation.
As for implementation, I recommend a timer queue if the application runs in NT and newer versions of Windows. Otherwise, implement a worker thread to do the counting.
Kuphryn
-
October 30th, 2002, 07:03 PM
#3
A way in Windows using GetTickCount
In Windows:
// Application symbol TimeOut is 60 seconds
#define TimeOut 60000
// Application global data
DWORD LastTime;
In the main function you set first a value to LastTime:
LastTime = GetTickCount();
Each time your program receives user input updates LastTime:
LastTime = GetTickCount();
A second thread have a loop that compares:
if ((GetTickCount() - LastTime) >= TimeOut)
{
// make something to notify or display a message
// you can break the loop and end the thread
// or you can set LastTime = GetTickCount() again
// and continue the loop
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|