T
Tobias Mattsson
I have a console application that continously serves a set of network
connections, now i want to add a command prompt. So what i need is to poll
for pending input from System.Console in that loop and assemble lines to
interpret. Ive tried using OpenStandardInput to get a Stream object, but
there is no way to find out how much data is pending on such a stream. And
it doesnt support asyncronous operations through BeginRead. So im looking at
using async delegates, but as ive understood it they create a worker thread,
and since i need a call for each character that becomes a lot of overhead. I
could of course just throw console.readline in a thread of its own, but then
i get problems shutting that thread down. I need to get a waithandle from
somewhere and use that in a seperate thread or poll it in the main loop.
In Win32 id use GetStdHandle() to get a HANDLE and then WaitForSingleObject
to poll it, how can i do this in .NET ?
connections, now i want to add a command prompt. So what i need is to poll
for pending input from System.Console in that loop and assemble lines to
interpret. Ive tried using OpenStandardInput to get a Stream object, but
there is no way to find out how much data is pending on such a stream. And
it doesnt support asyncronous operations through BeginRead. So im looking at
using async delegates, but as ive understood it they create a worker thread,
and since i need a call for each character that becomes a lot of overhead. I
could of course just throw console.readline in a thread of its own, but then
i get problems shutting that thread down. I need to get a waithandle from
somewhere and use that in a seperate thread or poll it in the main loop.
In Win32 id use GetStdHandle() to get a HANDLE and then WaitForSingleObject
to poll it, how can i do this in .NET ?