Click here to Skip to main content
12,559,073 members (34,584 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB VB.NET
How to contonue program until not press any key in console application
Loop while <press any key>
Posted 23-Dec-12 19:50pm
What was wrong with just reading on System.Console? :-)

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Hell, no! Your loop is polling and is considered a very bad thing, especially in UI. What you need is this:

System.Console.Write("Press any key...");

The ReadKey call is blocking. Your thread will be put in wait state wasting not CPU time, will be waken up only when you actually press a key, all the way from triggering a hardware interrupt in OS kernel (or if you abort the thread or the whole process).


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.161026.1 | Last Updated 24 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100