|
-
August 12th, 2009, 05:52 AM
#1
How long will Sleep sleep?
Hello! I have a multithreaded application. I was wondering, if I do a Thread.Sleep(10*1000), will it do a sleep of 10 Seconds in "thread-time" or in "real-time"?
-
August 12th, 2009, 07:25 AM
#2
Re: How long will Sleep sleep?
I don't know what you mean by thread time, but that will sleep the thread for 10 seconds as measured by a clock on the wall.
www.monotorrent.com For all your .NET bittorrent needs
NOTE: My code snippets are just snippets. They demonstrate an idea which can be adapted by you to solve your problem. They are not 100% complete and fully functional solutions equipped with error handling.
-
August 12th, 2009, 08:03 AM
#3
Re: How long will Sleep sleep?
-
August 12th, 2009, 03:15 PM
#4
Re: How long will Sleep sleep?
Thread.Sleep is capable of sleeping for approximately 3 1/2 weeks.
it takes an int as it's parameter. the largest value of an int is 2^31 -1 which in this case is representative of milliseconds... you do the math.
-
August 12th, 2009, 08:10 PM
#5
Re: How long will Sleep sleep?
Keep in mind that sleep is an approximate wait period.
Since any threads with higher priority are scheduled before threads of lower priority, a lower priority thread may effectively continue to 'sleep' even after the sleep period has expired. This is because the scheduler will continue to run the higher priority threads until they've finished their work before scheduling the lower priority thread. If the sleep value in the lower priority thread has expired, then it will run (but this could be well after the intended sleep period).
All that being said, generally there is little reason to use sleep.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|