Thread overview | |||||
---|---|---|---|---|---|
|
March 22, 2014 More updated question about Sleep/msleep/usleep | ||||
---|---|---|---|---|
| ||||
Hello, I know there are severel threads concerning "Wait", "Pause", "Sleep", a.s.o but most of them were created in 2007 or similiar. It seems D has changed a lot because when I try to call sleep/msleep (example), the compiler cannot find it (ERROR: undefined indentifier). import std.stdio; /// .... other imports as well import std.c.time; main_bock() { //// init and things sleep(1); // not found std.c.time.sleep(2); // not found as well std.c.time.msleep(1000); // nope... /// continued code } So, is there a newer version? I get a hint for thread.sleep but this may be a member function. Also, i suppose I MAY use Sleep() from windows.h, if there is no other option. |
March 22, 2014 Re: More updated question about Sleep/msleep/usleep | ||||
---|---|---|---|---|
| ||||
Posted in reply to BeschBesch | import core.thread; void main() { } |
March 22, 2014 Re: More updated question about Sleep/msleep/usleep | ||||
---|---|---|---|---|
| ||||
Posted in reply to BeschBesch | This will work: import core.thread; void main() { Thread.sleep(5.seconds); } sleep is a member of Thread, but it is static so you can easily call it to sleep the current thread. The argument is a Duration, which is most easily constructed with the .seconds, .msecs, .minutes, etc. helper functions like I did here. |
Copyright © 1999-2021 by the D Language Foundation