Solved

About timer in MFC

Posted on 2000-03-02
5
177 Views
Last Modified: 2013-11-20
Hello,

I am developing an application in VC++ 5.0/MFC. This application is to be run for 2000 hrs. continuously. I have to take readings periodically using this application. For that i am using StartTimer() and KillTimer(). I want to ask whether they work perfectly for this much long time and also if windows OS is run for 2000 hrs is it ok? Will it cause time lag after some time or not ? Thanks.
0
Comment
Question by:namrata
  • 2
  • 2
5 Comments
 
LVL 1

Expert Comment

by:poohbear_68
ID: 2578662
Timer handlers are not guaranteed to be called.  Depending on the circumstance (e.g. Windows is busy doing something else), they may not be called.  You will want to have the intervals fairly frequent because of this.

I haven't really researched it, but (other than first paragraph) I would think that it should be fairly reliable.

Timers are not precise, so you may wish to check out another method.
0
 

Author Comment

by:namrata
ID: 2578684
Can u suggest any other method?
0
 
LVL 10

Accepted Solution

by:
RONSLOW earned 5 total points
ID: 2578922
run the timer function very often and check the actual time.  If the current time is >= the time for the next reading, then take it.

The accuracy will then depend on how often the timer fires.  eg if readings are to betaken every minute, and the timer fires every second, then the readings should be accuractly to the nearest second (approx).

If you want it more exact, wait until you are within a certain (small) time before the even you want and then just go into a while loop checking for the time. (eg. if you are within 1 second before the nextreading, do a loop checking the time until the time is >= what you need).

how to do it really depends on how accurately and frequently the readings are to be taken.

0
 

Author Comment

by:namrata
ID: 2582986
ok. i have to take readings minimum at 1 minute. so accuracy should not be much problem.  What about windows OS? Any problem if it is run for a long time?
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 2585958
You're leaving yourself open for a lot of anti-MS comments here :-)

Windows OS should be fine for long periods.  Win2000 especially as it has been written for use in servers (which are supposed to have very high availability).  I don't thinkg you'll find the OS itself is really a problem.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

803 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