What's the equivalent of sleep(), wait(), or pause()

James Pelcis jpelcis at gmail.com
Sat Jul 8 13:08:08 PDT 2006


In this case, the best solution would likely be std.c.time.

# private import std.c.time, std.stdio;
#
# void main () {
#	writefln("Hello World.");
#	sleep(2);
#	writefln("Goodbye World.");
# }

I don't know of any pure D ways to do this in Phobos.  The closest I 
could think of is in std.thread and is specifically prohibited...

# private import std.thread, std.stdio;
#
# void main () {
#	writefln("Hello World.");
#	std.thread.Thread.getThis.wait(2000);
#	writefln("Goodbye World.");
# }

I don't know why that is though.  My guess would be it's to cover up 
limitations in the operating system thread implementations.  Can anyone 
confirm that?

Charles D Hixson wrote:
> Alternatively, where in the documentation can I find it.
> 
> What I want to do is to wait for a couple of seconds with a
> message on the screen before continuing.  I thought I knew
> the answer (sleep(2) ), but that was the bash
> command...what's the D equivalent?  Or do I just need to
> build a do-nothing loop with a LONG countdown?  (That would
> be a bad answer, because I don't really want to eat system
> resources just because I'm waiting.)



More information about the Digitalmars-d-learn mailing list