Interesting Thread.sleep error in Mono-D

Jeremy DeHaan dehaan.jeremiah at gmail.com
Tue Aug 21 00:07:09 PDT 2012


I was playing around with various parts of D today and I got this 
very strange error when I call Thread.sleep() in my code in 
Mono-D.

First, I'll post the code:

module main;

import std.stdio;
import core.thread;

void main(string[] args)
{

	int i = 0;
	
	while (i < 10)
	{
		writeln(i);
		Thread.sleep(dur!("msecs")(500));
		i++;
	
	}
	

     // Lets the user press <Return> before program returns
     stdin.readln();


The funny thing is, the code compiles fine. When I run it via the 
console(in Windows) it runs as expected. When running it through 
MonoDevelop/Mono-D, however, I don't see any output until the 
program stops running and then I see it all at once along with 
this set of messages.

std.stdio.StdioException at std\stdio.d(2301): Bad file descriptor
----------------
0x00415C1C in char[][] 
core.sys.windows.stacktrace.StackTrace.trace()
0x00415AA7 in core.sys.windows.stacktrace.StackTrace 
core.sys.windows.stacktrace.StackTrace.__ctor()
0x0040960B in void std.stdio.StdioException.opCall()
0x004027F4 in uint std.stdio.File.readln!(char).readln(ref 
char[], dchar) at C:\D\dmd2\src\phobos\std\stdio.d(835)
0x00402770 in immutable(char)[] 
std.stdio.File.readln!(immutable(char)[]).readln(dchar) at 
C:\D\dmd2\src\phobos\std\stdio.d(792)
0x00402053 in _Dmain at 
C:\Users\Jeremy\Documents\Projects\Test2\Test2\main.d(28)
0x004052E4 in extern (C) int rt.dmain2.main(int, char**).void 
runMain()
0x0040531E in extern (C) int rt.dmain2.main(int, char**).void 
runAll()
0x00404F40 in main
0x0041D4B5 in mainCRTStartup
0x75D2339A in BaseThreadInitThunk
0x77709EF2 in RtlInitializeExceptionChain
0x77709EC5 in RtlInitializeExceptionChain
----------------
0

1

2

3

4

5

6

7

8

9

The application exited with code: 1



Am I actually doing something wrong? Or is this just something 
going on with Mono-D?


More information about the Digitalmars-d-ide mailing list