Saturday, May 2, 2015

Console.ReadLine() not working with .net Framework > 3.5

There is indeed a change that was introduced in .NET 4, when reading from a console stream it first tries to wait on the stdout handle before actually reading from it:

http://ift.tt/1boGFSp

That's a bit odd as this appears to end up calling WaitForMultipleObjects on a pipe handle and such handles aren't specifically supported by Win32's wait functions. This usually works but somehow this fails in the case of QT which probably has its own weirdness (using IO completion ports to read from the process's output, sort of overkill).

Consider opening a bug report on Connect to see what MS has to say about this.

As a workaround consider using Win32 functions directly to start the process - CreatePipe, CreateProcess... I tried that and it seems to work fine.


No comments:

Post a Comment