?
Solved

Timer routine

Posted on 2003-03-18
3
Medium Priority
?
262 Views
Last Modified: 2010-04-17
Hi all!

Can anyone please tell me how I can make a tiny timer routine which reads the clock on the computer and prints out text in given intervals? Ie after every 5 or 10 seconds (something like an alarm clock...) Must be in plain cpp for a console window project i'm working on...

Sunb!

0
Comment
Question by:Sunblock
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Accepted Solution

by:
poor_guy earned 150 total points
ID: 8171335
void doTimer()
{
  while(true)
  {
    CTime t = CTime::GetCurrentTime();
    CString cstrCurrTime = t.Format(_T("%b/%d/%Y,%H:%M"));
    cout << cstrCurrTime;
    if (isExit == true)
    {
      break;
    }
    sleep(5000);
  }
}

This function will go to sleep for 5 seconds and loop until some other thread has set the isExit variable to true. You need use MFC for this.

Hope this helps.
0
 

Expert Comment

by:CleanupPing
ID: 9447043
Sunblock:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 

Author Comment

by:Sunblock
ID: 9449956
I think this is a good routine giving me just what I wanted...
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question