Timer check without interupth the program gets slow or stuck
Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
3 posts
Page 1 of 1
Hello,
we like to get a timer that checks when the system date change
so we suppose to check it every hour or a complete day...
then to refresh our form
but no idea how to do it and even without to make the program slow or cpu overloading
Thanks.
we like to get a timer that checks when the system date change
so we suppose to check it every hour or a complete day...
then to refresh our form
but no idea how to do it and even without to make the program slow or cpu overloading
Thanks.
visit us on:
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
Here's a snippet that is meant to run every hour, exactly on the hour:
Code: Select all
Should be easy to incorporate in to your code. Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim aTimer As New System.Timers.Timer(MillisecondsToNextTopOfTheHour)
AddHandler aTimer.Elapsed, AddressOf OnTimedEvent
aTimer.Start()
End Sub
Private Shared Sub OnTimedEvent(source As Object, e As System.Timers.ElapsedEventArgs)
Dim aTimer As System.Timers.Timer = CType(source, System.Timers.Timer)
aTimer.Stop()
'Enter code here to change your calendar or whatever you need to happen each hour
aTimer.Interval = MillisecondsToNextTopOfTheHour()
aTimer.Start()
End Sub
Private Shared Function MillisecondsToNextTopOfTheHour() As Double
Return DateTime.Today.Add(New TimeSpan(DateTime.Now.Hour, 0, 0)).AddHours(1).Subtract(DateTime.Now).TotalMilliseconds
End Function
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
Okay Thanks Codenstuff
lets see what i can do with it ;)
Edit:
Just wonderful and no much cpu at all either
thanks ;)
Dummy
lets see what i can do with it ;)
Edit:
Just wonderful and no much cpu at all either
thanks ;)
Dummy
visit us on:
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
3 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023