Solved

NT Timer Routine

Posted on 1997-12-09
5
193 Views
Last Modified: 2010-04-10
I am trying to write a C++ console program running in NT Server-DOS process which would be able to do a countdown of time defined by the user as well as exit the countdown based on the user input. The current program takes a lot of system CPU resource to countdown to a pre-determined time interval. DOes WIN32 provide an API which will return time without eating the CPU resource.
0
Comment
Question by:rian
  • 3
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 50 total points
ID: 1175524
One way to do it is to use SetTimer() and provide a callback function. This function will get called after the time has expired. Another possibility would be to use Sleep(). This puts the entire process to sleep for the entire length you specified. Upon which, your program continues from the point of calling Sleep().

0
 

Author Comment

by:rian
ID: 1175525
Apparantly, the Sleep function does not work on a console application. Is that true
0
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1175526
That is NOT true. I have written console applications that use Sleep. The console applications have access to most of the Win32 API.

0
 

Author Comment

by:rian
ID: 1175527
I do not dispute what u are saying. Unfortunately, I have not been able to compile with the sleep API. I have included windows.h, winbase.h. Also, added Kernel32 in the link lib setting.

Could u tell me which header file is required to compile. Currently, the compiler tells me that sleep in a unknown identifier.
0
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1175528
All you need is winbase.h. Make sure you are using Sleep() and not sleep().


0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Implementing a ResolveEventHandler in C++ 13 114
C++ assignment question 7 165
How can i compile this github project?? 2 74
passing data from one form to another form in c++ 27 72
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

929 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now