Hi all ,
I have two times like 5 AM and 6PM a service should start on
Every time this service starts it checks and schedule itself to the coming time .
I am trying this but it does not work some times
I am changing time so I test it but sometiimes it just does not start
Please help
I have two times like 5 AM and 6PM a service should start on
Every time this service starts it checks and schedule itself to the coming time .
I am trying this but it does not work some times
B4X:
Sub Schedule(hs As Long,ms As Long)
Dim alarm As Long
DateTime.TimeFormat="HH:mm:ss"
Dim today As Long
today = DateTime.DateParse(DateTime.Date(DateTime.Now)) 'Sets today at 12:00 AM
alarm = today + hs * DateTime.TicksPerHour + ms * DateTime.TicksPerMinute + DateTime.TicksPerMinute
If alarm < DateTime.Now Then alarm = DateTime.Add(alarm, 0, 0, 1)
Dim h, m As Int
h = Floor((alarm - DateTime.Now) / DateTime.TicksPerHour)
m = ((alarm - DateTime.Now) - h * DateTime.TicksPerHour) / DateTime.TicksPerMinute
CancelScheduledService("")
StartServiceAt("", (DateTime.Now+((h*60*60*1000)+(m*60*1000))), True)
End Sub
Please help