do sthing at specified date & time

mirzao

Active member
Joined
Nov 10, 2005
Messages
44
Location
Malaysia
Programming Experience
Beginner
Hi guys,
I want my application to start doing something at specified date and time i've thought about this and if I'm not mistaken there are 2 ways of doing it. Firstly, if it has run for 24 hrs it then do sth or if time=6 a.m then do sth. But I don't know what is the correct coding. Can anyone please help. Thank you
 
Add a Timer to your app. If it's on a Form then use a Windows.Forms.Timer, otherwise use a Timers.Timer. Calculate the number of milliseconds to the time you want this something to happen and set that as the Interval of the Timer. Handle the Tick or Elapsed event, depending on which Timer you use, and perfrom the desired action there. Note that the Timers.Timer will stop at that point by default, which behaviour you can change if you want, while the Windows.Forms.Timer will continue raising events on the Interval until you Stop it.
 
Yes

Yes this is possible all the stuff that you would need for this is in the System.Datetime class and within the timer or new to 2.0 stopwatch. With these three things you should be able to control how things happen based on intervals of time and based on the current time on the machine.
 
One nasty way of doing it is writing a module wich checks your date and time, you can let the thread sleep every 5 seconds and then recall sub main.
One thing you could do so it automaticle starts up is put it in your windows/run regkey. I used to write annoying little virusses for friends at school that way :p
 
Back
Top