473,662 Members | 2,724 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sleep

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
Nov 20 '05 #1
2 1133

"Tony" <To***********@ msn.com> wrote in message
news:OQ******** ******@tk2msftn gp13.phx.gbl...
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(ByVa l untilWhen As DateTime)
Dim wakeUp As TimeSpan = untilWhen.Subtr act(Now)
If TimeSpan.Compar e(wakeUp, TimeSpan.Zero) = 1 Then
System.Threadin g.Thread.Sleep( untilWhen.Subtr act(Now()))
End If
End Sub
David
Nov 20 '05 #2
System.Threadin g.CurrentThread .Sleep(New Timespan(1,0,0) )
where 1 is one hour

Gerasha

"Tony" <To***********@ msn.com> wrote in message
news:OQ******** ******@tk2msftn gp13.phx.gbl...
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

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
13973
by: Anks | last post by:
hi I am displaying a digital clock in an applet.I am using Thread.sleep (1000) for counting every second.This works fine some times but some times my clock just slows down or give an interrupted exception .I am not calling Thread.interrupt anywhere in my program. why is it happening? how to fix the problem? Anks
7
10260
by: Colin Brown | last post by:
Python 2.3.3 Under Windows NT: Negative Int or Real -> sleeps for a long time Under Linux: Returns IOError: Invalid argument I consider both of these unfriendly results and expected the preferable silent time.sleep(0) in much the same way that slicing a string beyond the ends returns an empty string. Colin Brown PyNZ
5
5534
by: Dave | last post by:
For the life of me, I thought there was a sleep() function in the Standard Library (or something similarly named), but I can't find it. Is it non-existent or, if not, what header is it in? Thanks! Dave
21
18712
by: Alo Sarv | last post by:
Hi From what I have understood from various posts in this newsgroup, writing event loops pretty much comes down to this: while (true) { handleEvents(); sleep(1); // or _sleep() or nanosleep(), depending on platform }
8
2777
by: Cider123 | last post by:
I ran into a situation where my Window Service had to process 100,000+ files, when I first noticed I needed to tweak various routines. Everything runs fine, but here's what I ran into: In the routine that loops through the file buffer: for (int i=0;i < _Buffer.length; i++) { // Code here
9
3482
by: Chris Dunaway | last post by:
According to the docs, calling Thread.Sleep(0) causes the thread to be "suspended to allow other waiting threads to execute." What happens if I call Thread.Sleep(500)? Do other threads not get a chance to execute during this time? What is the difference between the two? I have code that runs in a loop like this: Dim dResetTime As DateTime = DateTime.Now
17
6409
by: OlafMeding | last post by:
Below are 2 files that isolate the problem. Note, both programs hang (stop responding) with hyper-threading turned on (a BIOS setting), but work as expected with hyper-threading turned off. Note, the Windows task manager shows 2 CPUs on the Performance tab with hyper-threading is turned on. Both Python 2.3.5 and 2.4.3 (downloaded from python.org) have this problem. The operating system is MS Windows XP Professional.
1
2764
by: Matt Brown - identify | last post by:
Hello, I, as well as suspecting many others, am having an issue when I attempt to enter sleep mode in Vista. If any program is connected to the internet (AOL Instant Messenger for instance), and I go to enter Sleep mode; Vista will automatically leave Sleep mode immediately. I believe this is caused by the fact that Sleep attempts to disconnect AIM, then AIM attempts to reconnect; thrwarting Vista's attempt to
13
5821
by: Charles Zhang | last post by:
Sleep() function Sleep at lease 1 millisecond, there is a way to make a thread to sleep less than a millisecond? One way I know of is using performance counter which is not really sleep ( loop and check again and again and uses CPU time). Thanks Charles Zhang
0
1395
by: Tim Golden | last post by:
Lowell Alleman wrote: Well you've certainly picked a ticklish area to run into problems with ;). First, forget about the threading aspects for the moment. AFAICT the smallest program which reproduces your problem is: <code> import signal
0
8345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
7368
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5655
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4181
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4348
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2763
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1999
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1754
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.