On Wednesday, 25 March 2015 at 17:23:40 UTC, Israel wrote:
What is the proper way of adding sleep time to a program?
The documentation examples are exactly how you can do it:
Thread.sleep( dur!("msecs")( 50 ) ); // sleep for 50 milliseconds
Thread.sleep( dur!("seconds")( 5 ) ); // sleep for 5 seconds
Try one of those lines in your program and you'll see it work.
You can also call the various C functions to do it but the
Thread.sleep is often a bit easier.
The documentation examples dont make sense. Why would it work
this way?
sleep is a static method on the Thread class, so you need to call
it Thread.sleep instead of plain sleep, and the argument uses a
different type to make the units a bit more clear.
I believe
Thread.sleep(3.seconds);
shoudl also work.