Home | Index | Dotnet4all Snippets | Submit resources
About | Mail us 





sleep (Thursday, January 06, 2005)



Found the following interesting discussion in the Newsgroups:

sleep
by: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


 Reply:
by:David Browne

 
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


 Reply:
by:Herman Kheyfets

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

Gerasha



Posted by Xander Zelders



0 Comments:

Post a Comment

<< Home

 
Previous Posts
    - Web Custom Control - Datagrid Event Handling Probl...
    - Windows Services
    - installutill
    - Using Variable Control Name
    - Remoting and Windows Services
    - Creating a DSN via odbc - But do i need one at all...
    - Getting ASCII Output From Web (using wget)
    - Treeview highlight node on form load
    - Parsing a flat file to retrieve only a single line...
    - Is there something like this in VB.Net?



Disclaimer & Terms of Use | DotNet4All.Com concept & © 2004 - 2007 by Zelders² - Holland