set up timer start 15 sec past minute

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, All,

My question is how to set up timer start 15 sec past minute. It always start
15
sec past minute. For example, if current time is 8:30:45, the timer starts on
8:31:15 am; if current time is 8:00:00, the timer starts on 8:00:15; if
current time is 8:55:15, the timer starts on 8:55:15, if current time is
8:59:00, the timer starts on 8:59:15 ..., so the timer always starts 15
seconds past minute, can anyone help this out?

Thanks in advance
 
Hello martin1,

why not just have yer timer fire every half second and the first thing you
check is the current time.

-Boo
 
Thank you. Cor,

So the logic is retrive current second, if = 15 sec, then start timer

The code look likes:

Dim moment As New System.DateTime
Private Shared myTimer As New System.Windows.Forms.Timer()

Dim second As Integer = moment.Second

if second = 20 then
myTimer.Interval = 60000
myTimer.Start()
end if

Is this correct?

Thanks,
 
To get 15 seconds after midnight, use the following

Dim ts As TimeSpan = Now.Date.AddDays(1).AddSeconds(15) - Now

All the timer controls in dotNet can set their interval using a timespan
object.

Mike Ober.
 
Martin,

No of course not. Something as

Dim moment As New System.DateTime
Private Shared myTimer As New System.Windows.Forms.Timer()

Dim second As Integer = moment.Second
if second < 16 then
myTimer.Interval = Cint(14 * 1000)
else
myTimer.Interval = CInt(second * 1000)
end if
myTimer.Start()

I did not check this, but something as this,

Cor
 
Hi, Cor,

the timer interval = 60 sec (60000milSec), I want timer starts 15 sec past
minute no matter when start the application, the app has the timer to refresh
data. so how to change the code? Thanks
 
Back
Top