469,312 Members | 2,496 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,312 developers. It's quick & easy.

How to wait

How do I tell my application to wait for 2 seconds?
Nov 24 '06 #1
6 46668
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Danny Masti | last post: by
2 posts views Thread by Rasmus Grøndahl Olsen | last post: by
22 posts views Thread by codefixer | last post: by
15 posts views Thread by Snuyt | last post: by
12 posts views Thread by Perecli Manole | last post: by
22 posts views Thread by Jason Zheng | last post: by
2 posts views Thread by greyradio | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.