Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sleep, delay...

Posted on 2000-05-06
7
Medium Priority
?
310 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
[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
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 600 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

610 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