press any key to exit

elloco999

Well-known member
Joined
Dec 21, 2004
Messages
49
Programming Experience
5-10
Hi,

I have a small console app that asks the user to press enter t exit. This is done, to let the user read the output before closing the app.

VB.NET:
[size=2]Console.Write("Press The 'Enter' key to close the application.")[/size]
[size=2]Console.Read()[/size]

I would like to change this, so that the user can press any key, instead of just enter. How can I do this?

Greetz,
El Loco
 
Nice ;)

But I wonder why it didn't work at tpm..

cya cowz
 
Why don't just let him do it? ;)
 
that might be but then again we can start discussing that a console app isn't very user friendly in these days of flashy GUI's

An console app is indeed not very user friendly. But why bother with a flashy GUI when all you want to do is to get some email adresses from a database every 3 hours and send these adresses an email?
Also, this app is going to run on a server, in the background and should consume the smallest possible amount of system resources. And a console app requires a lot less then a windows app with a flashy GUI...
And last but not least, by boss want's it to be a console app!

Greets,
El Loco
 
Someone's goin to have to press a key every 3 hours? Man I'm glad I don't work with you... :) Granted you can open multiple copies of your app but that will then be wasting your memory. Why not use a service? I would consider that a better option. If the server restarts the service will also. Just a thought.

TPM
 
Ok, bad example. As you correctly noted, when running on a schedule (like every 3 hours) the output isn't exactly wanted :) But the app can be run manually as well... So it has an parameter that turns off the output.

And you are right, I should use a service for this. But my boss didn't want that, so I didn't build that... I may still port it to a service, show him that would be better. Maybe he'll change his mind.

Greets,
El Loco
 
Back
Top