Solved

sleep, delay...

Posted on 2000-05-06
7
298 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
Technology Partners: 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 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C++ assignment question 7 269
C++ BOOL WINAPI ReadFile fails on windows 10 when reading from USB cable 9 520
Fully specialized class template function 21 147
Gaming Software 1 30
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…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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.

726 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