473,320 Members | 1,794 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,320 software developers and data experts.

Ending a Console.ReadLine() in C#

Hi all,

Does anyone know how to end a Console.ReadLine() 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 6078
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*******@hotmail-dot-com.no-spam.invalid> wrote in message
news:40**********@Usenet.com...
Hi all,

Does anyone know how to end a Console.ReadLine() 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*******@hotmail-dot-com.no-spam.invalid> wrote in message
news:40**********@Usenet.com...
Hi all,

Does anyone know how to end a Console.ReadLine() 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
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...
6
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); } ...
5
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...
12
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...
1
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...
1
by: Joachim | last post by:
Is there a way to set a timeout for the Console.ReadLine method?
2
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...
1
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
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.