read console

F

Frank

Hello,
in a consoleapp I have a continious loop doing stuff.
Additionally I want during the loop type in characters and when the combined
chars form a word (ic 'test') I want to execute a method.
What could I use? Not Console.Read because it blocks the main loop. I would
need a asynchronous read of some kind. Anyone have a simple solution?
Thanks
Frank
 
F

Frank Eller

Hi Frank,
in a consoleapp I have a continious loop doing stuff.
Additionally I want during the loop type in characters and when the
combined chars form a word (ic 'test') I want to execute a method.
What could I use? Not Console.Read because it blocks the main loop. I
would need a asynchronous read of some kind. Anyone have a simple
solution? Thanks

IMHO no simple solution, no. I believe you need to get familiar with Threads
.... the System.Threading namespace is a good starting point.

Regards,
 
J

Jiri Zidek

What not use:
if( Console.In.Peek()>0 ) { .... read some chars... if comlete commend goto
execute ...} else { do something else }

Doc says: "The current position of the TextReader is not changed by this
operation. The returned value is -1 if no more characters are available. The
default implementation returns -1."

Pazu
 

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

Top