Console.Read()\ReadLine()
Messages   Related Types
This message was discovered on microsoft.public.dotnet.general.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Art
I am working on a console app and I can not find a way to "cancel" a Read or
ReadLine. The scenario is, an employee logs in and the application presents
him/her with a menu of choices they can make and an instruction "Enter a
number 1 - 10 and press [Enter]". The employee walks away from the device
while still logged in. After a period of time I want to log the employee out
and re-prompt for a login. But I can't cancel the read. When the next
employee tries to log in the read is expecting "1 through 10" data.

I have created a reader as its own object and tried to destroy it when the
timer fires but it appears the Read() takes precedence.

Thanks in advance.
Art
--
There are only 10 types of people in the world. Those that understand
binary and those who don't.
Reply to this message...
 
    
Kevin Yu [MSFT] (VIP)
Hi Arthur,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to cancel reading from console
when time outs. If there is any misunderstanding, please feel free to let
me know.

As far as I know, this is not possible. Because Console.Read method
executes synchronously. When Read is called, the program waits for console
to return.

Based on the document, this method will not return until the read operation
is terminated; for example, by the user pressing the enter key. If data is
available, the input stream contains what the user entered, suffixed with
the environment dependent newline character.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Reply to this message...
 
    
Art
Thank you Kevin. I was afraid that was the answer I would get. I'll try to
find a work around.

"Kevin Yu [MSFT]" wrote:

[Original message clipped]

Reply to this message...
 
 
System.Console




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com