|
-
May 25th, 2004, 02:42 PM
#1
Thread Starter
Hyperactive Member
No time for timers
Hi,
I'm writing a program that needs to run a sub once on the hour every hour.
is there w way to do this without using a timer control?
as this takes up too much reasources when running 24/7
Thanks
-
May 25th, 2004, 05:19 PM
#2
Hyperactive Member
You have to use some sort of timing object. Here is the way I would do it if I didnt' want to use a "visual control"
Code:
Private MyTimer As System.Timers.Timer
Private Sub MyTimerSub(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs)
'Code every hour goes here
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MyTimer = New System.Timers.Timer(3600000)
AddHandler MyTimer.Elapsed, AddressOf Me.MyTimerSub
MyTimer.Start()
End Sub
-
May 25th, 2004, 05:27 PM
#3
Thread Starter
Hyperactive Member
that is exactly what I >>am<< using.
The problem is that the timer is going tick tick tick tick.... tick tick tick... and every time that timer ticks it uses a percentage of memory after a few days of running the computers it is running on has slowed down, due to the timer using all the resources.
I wanted to know if there was a way to run the sub using the system clock? so when it was exactly an hour from last run it will run again.
-
May 25th, 2004, 05:35 PM
#4
Fanatic Member
I think that no matter what you do, you'll have some process running at all times checking on the time to see what time it is.
Your best bet would be to setup the scheduler that comes with WinXP to schedule the app to run every hour. They windows is doing all the processing and your app will only run every hour.
www.RealisticGraphics.net
Running VS.Net Enterprise & VB 6
Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML
MSN Messenger: kmsheff
-
May 25th, 2004, 06:43 PM
#5
PowerPoster
No matter where it is done, a timer has to be involved.
-
May 25th, 2004, 07:11 PM
#6
PowerPoster
Hi,
You say that after a few days of running the timer has consumed too much of your resources. In the beginning of the sub you wish to run, set Timer.Enabled to false and then set it to true just before the sub is vacated when you will obviously have to synchronise the timer with the actual time.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
May 26th, 2004, 01:07 AM
#7
Thread Starter
Hyperactive Member
right ok thanks,
well never mind 
I have just added a log to the program, and I have just realised that the program runs every 10mins lol, in stead of every hour... oops... maybe changing that will help to.
Thanks again,
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|