hi
how to make program loop the job and after that sleep for 15 min
and after 15 min start again and do the job and after that sleep again
:afrog:
Printable View
hi
how to make program loop the job and after that sleep for 15 min
and after 15 min start again and do the job and after that sleep again
:afrog:
try using a timer to keep track of the current system time and preform operation every 15 minutes
can u give me example
in your timer event
you can set the timer interval to approx 1 minute (60000)vb Code:
Static startime As Date If startime = "12:00:00 AM" Then startime = Now 'to set a value first timer run If Now > startime Then dostuff ' run some other procedure startime = DateAdd("n", 15, Now) 'reset startime 15 minutes later
is run with time
i want it the program run every 15 min and sleep 15 and run again
hope u got it :bigyello:
Have you tried the code? Add a timer to your form and copy & paste sample code as suggested.
i did it and if the time is not 12:00:00 the code not running
i must put time with it like run my program in after 15 when time will be 2:00:00 PM
and i want it like this
i want my program do his job and sleep for 15 min and do his job again ....etc
i hope u got it
With the code that westconn1 provided, the 1st time the timer event is triggered, it will set the 15 minute marker exactly 15 minutes later, then "do stuff" when that marker elapses, set the next 15 minute marker, etc, etc. Did you enable your timer and give it a non-zero interval? If not, do that.
Here is another option if you want to dictate when the 1st event will occur or you start/stop your timer.
1. Declare a new variable at top of your form: Dim targetTime As Date
2. Be sure to set your timer's interval property to something like 30 seconds. Enabled=False
3. In your button click or whatever you use to start/stop the timer
:: When starting, set targetTime to the date/time when the 1st event should be run and enable your timer
:: When stopping, disable your timer
4. The timer event would look like this
As you can see there isn't much difference between the 2 methods.Code:If Now() => targetTime Then
' disable the timer
' call your routine that must be run
targetTime = DateAdd("n", 15, Now())
' re-enable the timer
End If