473,396 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

read console

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
Nov 16 '05 #1
2 2305
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,

--
Frank Eller
www.frankeller.de
Nov 16 '05 #2
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

"Frank Eller" <fe[NOSPAM]@frankeller.de> píąe v diskusním příspěvku
news:uD**************@TK2MSFTNGP10.phx.gbl...
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,

--
Frank Eller
www.frankeller.de

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Bill Cohagan | last post by:
I'm writing a console app in c# and am encountering a strange problem. I'm trying to use redirection of the standard input stream to read input from a (xml) file. The following code snippet is from...
3
by: Jerry | last post by:
I am having problem with Console.Read(), the Value I entered is not the value that store in my variable. public class Num { int num; Console.Write("Enter a number: "); num=Console.Read();...
9
by: JuanK | last post by:
hello, i'm trying to read a character from console just like getc function in c languaje i'm trying with WINAPI but dont works at this time.. other methods like clear screen works OK with the...
3
by: - Steve - | last post by:
Okay I call Console.Read() twice. However when I come up on my second Console.Read() ASCII character 10 is already on the console (that's a line feed). How do I clear out that line feed before...
5
by: BobC | last post by:
Article ID: 301225 I can't seem to get this code to work. I modified it alittle so I could try and figure out the exception. I keep getting an error on the " Do While (reader.Read()) " statement....
0
by: XML newbie: Urgent pls help! | last post by:
I am using VB.Net. My program is to connect to a remote IPAddress. Once, it verifies the login information it should display the SessionID and enable some button . I appreciate your help and thanku...
4
by: Henry | last post by:
for the following code snippet: int k; char c; while (true) { k = Console.Read (); if (k == -1) break; c = (char) k; Console.WriteLine ("Echo: {0}", c);
5
by: ashley.ward | last post by:
I am attempting to write a program with VB 2005 Express Edition which accesses an Oracle 9 database and dumps the results of three SELECT queries into a spreadsheet file once every hour. ...
4
by: Kuldeep | last post by:
Hi All, I am trying to read the contents of a page through its URL. My code snippet is as follows: public void mtdGetPageDataHWR() { HttpWebRequest objRequ =...
5
by: dm3281 | last post by:
Hello, I have a text report from a mainframe that I need to parse. The report has about a 2580 byte header that contains binary information (garbage for the most part); although there are a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.