-
June 22nd, 2009, 06:21 AM
#1
Thread sleep with double
Hello guys,
I want to wait a certain time but it wont be always integer values, but decimals also.
For example I want to wait half second and in my program it's used like 0.5.
Do you have any solution to this?
Best regards,
Raul Bolanos.
Last edited by raulbolanos; June 22nd, 2009 at 06:52 AM.
Reason: [SOLVED]
-
June 22nd, 2009, 07:16 AM
#2
Re: Thread sleep with double
The System.Threading.Thread.Sleep method's parameter is in milliseconds, so to wait for half a second do
Code:
System.Threading.Thread.Sleep(500);
Darwen.
-
June 22nd, 2009, 07:18 AM
#3
Re: Thread sleep with double
I would use the thread's sleep method. The parameter is ms and fine enough:
http://msdn.microsoft.com/de-de/libr...1t(VS.80).aspx
So in your case 0.5 seconds would be:
-
June 23rd, 2009, 04:59 AM
#4
Re: Thread sleep with double
Just multiply your value times 1000.
Code:
float delay = 0.5;
Threading.Sleep( delay x 1000 );
Keep in mind that the Sleep( ) method is approximate and the system doesn't guarantee that your thread will be woken up at the precise moment the time expires.
Btw, hopefully you are using Sleep( ) in a non-UI thread because otherwise you will hang the UI.
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
|