PEEK and READ again

  • Thread starter Thread starter PHead
  • Start date Start date
P

PHead

Ive searched usenet before, with nothing, so Ill go ahead and ask...

Does anyone know how to read from the keyboard buffer from a console
app, *without* blocking? I know about the PInvoke method and
SetConsoleMode to char, which I am doing, but there is still a problem.
What I need to do is immediately exit the code if nothing is in the
buffer. Peek-ing will work the first time only. After that, it blocks.

If this can't be done, then Im pretty much forced into writing my own
console-type of output, which I dont think Ive ever seen such code
written before. So, I guess its a 2-part question - *real* non
blocking reads or a .NET or COM custom console with that ability?

Thanks in advance
 
Do you know when 2.0 is due out? I'll have to read up on that. I did
find an ugly solution (works though)... I create a new thread that does
the read in an endless loop (yuck). If it finds a key, it updates a
property of the new thread. When I want to "non-block" read, I just
look at that thread property in the original thread.
 
PHead said:
Do you know when 2.0 is due out? I'll have to read up on that. I did
find an ugly solution (works though)... I create a new thread that does
the read in an endless loop (yuck). If it finds a key, it updates a
property of the new thread. When I want to "non-block" read, I just
look at that thread property in the original thread.

I believe 2.0 is due out early in November.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top