Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I'm so glad I found this site... Now I can get some sleep, because my problem is solved..."

Geography

Where in the world do Tek-Tips members come from?
wansink (Programmer)
2 Oct 99 19:55
I wrote a program that I want to terminate after a certain amount of time expires. I call a function to start the timer (I didn't use the timer control because the time interval is 10 minutes). In the function I set a start value that is equal to the timer's current value. Then I ask the function to call a sub routine that ends the program when the timer's value is equal to the start value + 600 seconds.

On my home PC this program always works fine. However, when I load it on old 486's at work the program works sometimes, but not always. Sometimes the timer fails to end the program. There doesn't appear to be any rhyme or reason - I can run the program twice and do the exact same things in the program and the timer will work one time and not the next.

I'd appreciate any thoughts as to what might cause this to happen.
Alt255 (Programmer)
4 Oct 99 4:45
You might try ending the program when the timer value >= start value + 600 seconds. Not too precise but, at least, the program will end.
elizabeth (IS/IT--Management)
5 Oct 99 10:38
In case it is a matter of your clock time on those 486's being too slow to catch the exact time, you might try trapping the value when you use the above code. Maybe you would have to give it a range rather than an exact milisecond. Finding out the clock speed of the slowest 486 might give you a better idea of what a reasonable range is.
Alt255 (Programmer)
5 Oct 99 16:31
Elizabeth, good suggestion but hard to implement on unknown systems (we all deal with them from time to time, or all the time). It's hard to nail a given millisecond on most systems because events are not held in suspension while other events take place.
The world refuses to stop spinning while we wait for a sparrow to fall.
elizabeth (IS/IT--Management)
5 Oct 99 16:52
Alt255, not sure I get you... do you mean it would be hard to implement a range such as :
timer value >= start value + 600 seconds and <= start value + 601 seconds?
Helpful Member!(2)  sparrow (Programmer)
8 Oct 99 0:05
The following is taken from an article by John Percival about making a lander game. It uses the timer event but actually calulates elapsed time since first called. This may be usefull for you

Option Explicit
'API Declares
Private Declare Function GetTickCount Lib "kernel32" () As Long

'Although the timer is set to go off every millisecond, it does not really fire 1000 times every second, so we must 'find another way to measure the time between one call and the next. We will do this by using a static variable. 'This kind of variable retains its value between callings of a procedure. Therefore, if its value is set to 1 at the end of 'one calling, it will still be 1 next time it is called. Put these declarations into the Timer event:
Static curtime As Long
Dim timenow As Long
Dim timediff As Long
'The GetTickCount API function returns the number of milliseconds elapsed since Windows started, so this is 'ideal. During each timer event, the static variable will be set with the number of milliseconds, then the next time 'the event is raised, we can work out how long it was since the last time the event was called

If curtime = 0 Then
timenow = GetTickCount
curtime = timenow
Else
timenow = GetTickCount
End If
timediff = timenow - curtime

You now have the elaspsed time since the event was first called.


Hope this is usefull


Sparrow
Alt255 (Programmer)
8 Oct 99 5:06
Nice snip, Sparrow, sorry about our spinning world. Elizabeth, even a 486 should be able to catch a one second range (unless there is more than a second of dedicated disk activity) but wansink wants to know how to terminate the program after ten minutes has expired. If the app is set to check for a range of ticks and misses it, the app fails to terminate and continues to check for another 24 hours. If the app checks to see if ten minutes has expired it is certain to succeed.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close