473,320 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to wait

How do I tell my application to wait for 2 seconds?
Nov 24 '06 #1
6 46831
If you just want your application to pause for two seconds you can use

System.Threading.Thread.Sleep(2000);

This will cause the current thread to wait for 2 seconds before
resuming where it left off

On Nov 24, 4:03 pm, "Alan T" <alanpltseNOS...@yahoo.com.auwrote:
How do I tell my application to wait for 2 seconds?
Nov 24 '06 #2
Just add to others - SpinWait to wait without relinquishing the CPU

--
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche


"Alan T" wrote:
How do I tell my application to wait for 2 seconds?
Nov 24 '06 #3
"Michael Nemtsev" <ne*****@msn.comwrote in message
news:60**********************************@microsof t.com...
Just add to others - SpinWait to wait without relinquishing the CPU
EEK, spin for 2 seconds! You should never do that. First off, you should never spin on a
mono cpu box, second you should never spin for anything longer than the time taken by a
transition into the kernel and back.

Willy.

Nov 24 '06 #4
I completely agree but lacking any other further information about
exactly what the application does and the context of the wait...

On Nov 25, 2:47 am, "Willy Denoyette [MVP]"
<willy.denoye...@telenet.bewrote:
"Michael Nemtsev" <nemt...@msn.comwrote in messagenews:60**********************************@m icrosoft.com...Just add to others - SpinWait to wait without relinquishing the CPUEEK, spin for 2 seconds! You should never do that. First off, you should never spin on a
mono cpu box, second you should never spin for anything longer than the time taken by a
transition into the kernel and back.

Willy.
Nov 26 '06 #5
<ni***********@iinet.net.auwrote in message
news:11*********************@l12g2000cwl.googlegro ups.com...
>I completely agree but lacking any other further information about
exactly what the application does and the context of the wait...
Hmm... not sure what you mean here, you know the difference between a Sleep and a SpinWait
do you?
You should never call SpinWait for as long as 2 seconds whatever the context.

Willy.
Nov 26 '06 #6
Sorry Willy - I had misread your post. But I dont recall saying you
should spinwait for 2 seconds? Instead of picking up on my mistakes
maybe you could use your time more productively to give an answer to
Alans initial question

For the benifit of anyone else -
Sleep - will relinquish control of the thread for the number of
milliseconds denoted by the parameter -technicaly it is removed from
consideration by the thread scheduler for that length of time
SpinWait - will effectively lock the current thread into a tight loop
for a specified number of itterations. Generally not recommended and is
only genuinely useful in a small number situations

:-)
Nick

On Nov 27, 2:38 am, "Willy Denoyette [MVP]"
<willy.denoye...@telenet.bewrote:
<nick.fletc...@iinet.net.auwrote in messagenews:11*********************@l12g2000cwl.go oglegroups.com...
I completely agree but lacking any other further information about
exactly what the application does and the context of the wait...Hmm... not sure what you mean here, you know the difference between a Sleep and a SpinWait
do you?
You should never call SpinWait for as long as 2 seconds whatever the context.

Willy.
Nov 26 '06 #7

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

Similar topics

3
by: Danny Masti | last post by:
Hello, I have a HIDDEN div with a "Please Wait Message". OnSubmit I show the hidden div with the "Please Wait Message". It works fine. But if I replace the "Please Wait Message" with an animated...
2
by: Rasmus Grøndahl Olsen | last post by:
I have tried to write a wait function but it seems like it will not brake the while loop. I tried two different solutions. Can anyone tell me what I am doing wrong, and come with another...
0
by: s_erez | last post by:
Hi, This is a realy tricky one. I have an ASP.NET application where some pages are reading data from a DB and presenting reports. In order for the user to wait while the page is reading data from...
22
by: codefixer | last post by:
Hi, I have a situation where I have to handle the following scenario. The main() must wait for child to complete or the main() must kill the child after 3 seconds and exit. /* Assume...
4
by: Sharon | last post by:
I wish to control other threads, that are warped with my own classes, so when they are in any wait state (lock(), Monitor.Wait(), ReadWriteLock.Wait(), Mutex.Wait(), AutoResetEvent.Wait(),...
15
by: Snuyt | last post by:
Hello, I want the program to wait a few seconds between executing code. It should look something like this: public sub xx() ...code... wait(2) 'wait 2 seconds ...code...
12
by: Perecli Manole | last post by:
I am having some strange thread synchronization problems that require me to better understand the intricacies of Monitor.Wait/Pulse. I have 3 threads. Thread 1 does a Monitor.Wait in a SyncLock...
4
by: MrDeej | last post by:
Hello guys! I am trying to use trevors wait function on my odbc database for a countdown function. But this function is not stable as it sometimes dosent actually wait before launching next line...
22
by: Jason Zheng | last post by:
This may be a silly question but is possible for os.wait() to lose track of child processes? I'm running Python 2.4.4 on Linux kernel 2.6.20 (i686), gcc4.1.1, and glibc-2.5. Here's what happened...
2
by: greyradio | last post by:
I've recently have been given an assignment to do and it seems that notify() does notify() any of the waiting threads. The project entails 10 commuters and two different toll booths. The EZPass booth...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.