473,569 Members | 2,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ending a Console.ReadLin e() in C#

Hi all,

Does anyone know how to end a Console.ReadLin e() programmically rather
than typing the enter key in C#?

I have tried just setting the class object that contains this line to
null, but unfortunately that doesn't clear it up because it is
waiting for a signal to reactivate itself. I thought that maybe a
could write the equivelant of an Enter key to the console? Not sure
how to do that ie "\r\n"? :?:

thanks in advance.

Nov 16 '05 #1
3 6100
Hi,

You could theoretically send '\r\n' to the process' standard input stream.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"talljames" <ta*******@hotm ail-dot-com.no-spam.invalid> wrote in message
news:40******** **@Usenet.com.. .
Hi all,

Does anyone know how to end a Console.ReadLin e() programmically rather
than typing the enter key in C#?

I have tried just setting the class object that contains this line to
null, but unfortunately that doesn't clear it up because it is
waiting for a signal to reactivate itself. I thought that maybe a
could write the equivelant of an Enter key to the console? Not sure
how to do that ie "\r\n"? :?:

thanks in advance.


Nov 16 '05 #2
http://groups.google.com/groups?selm...&output=gplain
--
Klaus H. Probst, MVP
http://www.vbbox.com/
"talljames" <ta*******@hotm ail-dot-com.no-spam.invalid> wrote in message
news:40******** **@Usenet.com.. .
Hi all,

Does anyone know how to end a Console.ReadLin e() programmically rather
than typing the enter key in C#?

I have tried just setting the class object that contains this line to
null, but unfortunately that doesn't clear it up because it is
waiting for a signal to reactivate itself. I thought that maybe a
could write the equivelant of an Enter key to the console? Not sure
how to do that ie "\r\n"? :?:

thanks in advance.

Nov 16 '05 #3
Thanks guys, sorry for getting back so late. Fixed it with a simple
flag inside a ;; and a Thread.Sleep, which pops out every so often to
check the flag. Works much better and doesn't consume as much
resources and doesn't limit other graphics operations.

cheers
James

Nov 16 '05 #4

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

Similar topics

11
20887
by: William Stacey [MVP] | last post by:
Trying to test a simple console app that reads from standard in if you pipe input into it like: "c:\ type config.txt | consoleinput.exe" Seem to run into an issue. It seems like if you use a pipe, you can read all the input lines fine until eof. However, if you need to then prompt for input, the pipe is still hooked up so Read or ReadLine...
6
5115
by: Kristoffer Persson | last post by:
I have a small console app that has a Run method like this: public void Run() { m_Timer = new System.Timers.Timer(1000); m_Timer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimer); } The problem is that the code obiously exits the Run method immediately. What I want is for my application to do nothing but handle timer events and
5
6327
by: Publicjoe | last post by:
I am working on a little app which uses colour in the console window. I have created a class to extend the console functionality but the ClearScreen method does not work correctly. I am enclosing a complete project to show what happens. If anybody has an idea of how to fix this, please let me know. Yes I am aware that this is all in .Net 2....
12
3734
by: Jarod_24 | last post by:
I got a project called "Forms" that hold some forms and stuff in my solution. A argument at startup defines wether to use a From or Console. My plan was to create a myConsole class that would also allow my application to display a Console, but i don't seem to be allowed to do this. I don't see any References that i need to add, so how...
1
5181
by: Kevin | last post by:
In a newsgroup thread from Jan 8, 2003 between Barry Holsinger and the VBDotNet Team, please review this excerpt: "You understood my problem completely. Your sample code provides a really elegant way to inject CrLf into the input stream, which effectively unblocks the ReadLine method. Last night, I had finally got the WriteConsoleInput
1
4922
by: Joachim | last post by:
Is there a way to set a timeout for the Console.ReadLine method?
2
14342
by: SriBhargav | last post by:
Hi, I've a question on setting timeout on console.readline() I would like the user to input something through Console.readline() in 5 secs. If there is no input in that time, I would like to proceed further with the program logic. I had a difficulty in implementing this, as console.readline() indefinitely waits for the user input.
1
1696
by: Allen Maki | last post by:
Hi everybody, I need your help. I am using Visual C++ .NET How can I make Console::ReadLine accepts int? In other words. I know I can do this:
12
6512
by: Dilip | last post by:
Hi All I have a server based C# console application. This application must hide its console window when its launched out on the field. So I dutifully P/Invoke'd FindWindow/ShowWindow combination to hide the console window at launch time. The application (for legacy reasons) hangs around by waiting on an old- fashioned...
0
7922
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8119
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6281
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5218
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.