473,698 Members | 2,411 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 6123
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
20908
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 returns with -1 or null after that point. So you can't prompt for "Hit a key to continue", etc....
6
5123
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
6339
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. Thanks in advance.
12
3749
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 do i do this.
1
5191
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
4931
by: Joachim | last post by:
Is there a way to set a timeout for the Console.ReadLine method?
2
14377
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
1703
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
6536
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 Console.ReadLine() statement.
0
8685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8880
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6532
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5869
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2342
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2008
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.