sleep

  • Thread starter Thread starter Tony
  • Start date Start date
T

Tony

I want my program to sleep (do nothing) for one hour.
I can use the timer and 3600 seconds and code around the midnight problem.
is there a better way?
I looked at datediff, hour, minute, second still have to worry about
midnight.

Thanks
 
Tony said:
I want my program to sleep (do nothing) for one hour.
I can use the timer and 3600 seconds and code around the midnight problem.
is there a better way?
I looked at datediff, hour, minute, second still have to worry about
midnight.

How about this:

Public Sub SleepUntil(ByVal untilWhen As DateTime)
Dim wakeUp As TimeSpan = untilWhen.Subtract(Now)
If TimeSpan.Compare(wakeUp, TimeSpan.Zero) = 1 Then
System.Threading.Thread.Sleep(untilWhen.Subtract(Now()))
End If
End Sub


David
 
System.Threading.CurrentThread.Sleep(New Timespan(1,0,0))
where 1 is one hour

Gerasha
 
Back
Top