Solved

sleep, delay...

Posted on 2000-05-06
7
291 Views
Last Modified: 2010-04-02
I want my program to make something every 60 seconds.
What code should I use, so that my programm really sleep a whole minute, I mean, almost without consuming time of the processor?
0
Comment
Question by:javigil2
7 Comments
 

Author Comment

by:javigil2
ID: 2784530
Adjusted points from 100 to 150
0
 

Expert Comment

by:GabeSmed
ID: 2784556
Maybe you could create a timer using Set_Timer, and then add the code to make your program do whatever on the WM_TIMER event.  That's using Microsoft Visual C++, by the way.
0
 

Expert Comment

by:GabeSmed
ID: 2784565
I'm sorry, I was very vague with my first answer.  Use SetTimer (NOT Set_Timer - whoops) in your OnInitDialog function (or a function called at the start of your program) using this format.

SetTimer(your timer ID - you can add one in the string table or just choose a number, interval in milliseconds, NULL)

Add a KillTimer(timer ID) function at the end of your program.

Finally, in the OnTimer event (WM_TIMER messade), add your code to be performed every minute.

I hope this is better.
0
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.

 

Expert Comment

by:GabeSmed
ID: 2784567
you can look up these functions in the MSDN library if you need more information
0
 

Expert Comment

by:GabeSmed
ID: 2784568
you can look up these functions in the MSDN library if you need more information
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 2784590
If your program doesn't have windows, use Sleep().
0
 
LVL 1

Accepted Solution

by:
Toad224 earned 150 total points
ID: 2784853
if your program is using Windows, you could use the SetTimer() API.  To use this call SetTimer(1, 60000, NULL); within the InitDialog of your program.  The command executed will be WM_TIMER.  Make your program handle WM_TIMER, the argument wParam (or nIDEvent if you are using MFC) will == 1 if it is that timer.  Therefore (within WM_TIMER event):

if(nIDEvent == 1)
{
   //Put code here that should be executed every minute
}
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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

910 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

20 Experts available now in Live!

Get 1:1 Help Now