Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 313
  • Last Modified:

sleep, delay...

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
javigil2
Asked:
javigil2
1 Solution
 
javigil2Author Commented:
Adjusted points from 100 to 150
0
 
GabeSmedCommented:
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
 
GabeSmedCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
GabeSmedCommented:
you can look up these functions in the MSDN library if you need more information
0
 
GabeSmedCommented:
you can look up these functions in the MSDN library if you need more information
0
 
NickRepinCommented:
If your program doesn't have windows, use Sleep().
0
 
Toad224Commented:
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now