Solved

About timer in MFC

Posted on 2000-03-02
5
184 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
[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
  • 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

Industry Leaders: 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!

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

687 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